Hi Brad, Sorry, I think I failed to communicate what the problem was. (Sorry for caps, just emphasising the keywords) Please read my full e-mail I do NOT want to have a relocatable build file. I do NOT want to set CMAKE_USE_RELATIVE_PATHS to "True" (the default is False).
I NEED absolute paths in my build files. I believe cmake intends to supply absolute paths in my case (and indeed reading the code, the writer expects this to be the case). But it currently does NOT. The fact that it doesn't, is why I am emailing with a fix! The problem is that the Visual studio generators currently ALWAYS Generate RELATIVE paths. Sorry to take so much of your time, but I genuinely believe this is a bug, and your previous e-mail has dismissed it as by design, I can almost guarantee you that it is not CMAKE's intention to be always generating relative paths in VisualStudio generators. I'm sure you will agree with that statement. If you read below, I hope you will agree this is a bug, and can be fixed easily! For an explanation why Visual Studio project files should have absolute files when possible, see the bottom of this email: (I think you already know this though) If you read the code for cmVisualStudio10TargetGenerator::writeSource You will notice that it is written assuming that absolute paths are always generated by default, and that under some circumstances it will force the path to relative. This assumption is broken!! Please look at this commit: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4248132e59a8401a96d9c20ef155d80e439e7346 In that commit, the function "convertPath" is created to choose between relative/absolute. The bug is that this new "convertPath" function ALWAYS chooses relative! The original code that it is replacing it my reason for wanting this change, it said: - if(relative) - { - // custom command sources must use relative paths or they will - // not show up in the GUI. - sourceFile = cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - sourceFile.c_str()); - } - else - { - // do not use a relative path here because it means that you - // can not use as long a path to the file. - } The "Else" here is exactly why I need absolute paths and I'm sure it is the intention of Cmake to use them. If you look at the contents of this new "ConvertPath" +std::string +cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path, + bool forceRelative) +{ + return forceRelative + ? cmSystemTools::RelativePath( + this->Makefile->GetCurrentOutputDirectory(), path.c_str()) + : this->LocalGenerator->Convert(path.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED); +} So, if forceRelative == True, then we will generate a relative path. if forceRelative == False, then: this->LocalGenerator->Convert(path.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED); This function will ALWAYS generate a relative path when called like this!!! (because the default parameter "optional" is set to "false" by default) We need to change it to be: this->LocalGenerator->Convert(path.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED, true); (To tell it that the conversion is optional). Thanks for your time, sorry I have been so verbose, but your previous e-mail dismissing the issue meant that I needed to try to be as clear as possible. Joshua Green @Appendix: The reason I need absolute paths is because in visual studio a 260 character limit applies to file paths, and relative files mean that limit is reached much earlier than necessary. (because the relative path + the build file location must be < 260 chars). Currently CMAKE is generating relative paths in my projects of 160 characters length (with 6 ../../ on the front). These paths are then appended to my build file location (100chars in length). Causing the problem that visual studio cannot find these files. On Wed, Apr 9, 2014 at 3:32 AM, Brad King <brad.k...@kitware.com> wrote: > On 04/08/2014 04:58 AM, Josh Green wrote: >> I've got an issue with Cmake 2.8.12.2. >> The Visual Studio Generators do not abide by the >> "CMAKE_USE_RELATIVE_PATHS" setting. > > This option is not fully implemented or supported. The documentation > says that it does not fully work: > > http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_USE_RELATIVE_PATHS.html > > CMake is not intended to generate re-locatable or re-distributable > build files. If you *really* need them then you can use > -DCMAKE_SUPPRESS_REGENERATION=1 and post-process the generated > files to fix paths. > > -Brad > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers