[CMake] Generating stand-alone Visual Studio projects?

Petr Kmoch petr.kmoch at gmail.com
Tue Oct 15 04:56:58 EDT 2013


Hi Magnus.

I am afraid that's not really possible (safely). CMake uses absolute paths
all over the place (by design), so all output file paths etc. are hardcoded
in the .sln and .vc[x]proj files to the paths applicable where they were
generated. You can experiment with the variable CMAKE_USE_RELATIVE_PATHS,
but even its documentation warns that it's unreliable.

Petr


On Tue, Oct 15, 2013 at 10:23 AM, Magnus Therning <magnus at therning.org>wrote:

> Hi CMake list,
>
> A colleague and I are trying to somewhat sneak in CMake in a project
> that uses Visual Studio for IDE.  This is a fairly big step to take
> and we anticipate a bit of push-back, even if it clearly is a
> worthwhile improvement.  One way to maybe ease the transition would be
> to check in the CMake-generated solution+projects.  I took the naive
> approach and just removed the CMake-generated files, the cache etc,
> just keeping the VS solution+projects.  The next build I noticed that
> CMake was re-run and the cache was regenerated.
>
> Is there some way to get CMake to generate solution+projects that
> don't have any tie to CMake at all, its cache or CMakeLists.txt files,
> that are suitable to check into a VCS and thereby not require every
> user of the code to install CMake themselves?
>
> I am well aware of the potential problems arising from CMake not being
> a round-trip tool, i.e. that changes made to the solution+projects
> don't end up in the CMakeLists.txt automatically.  At this point in
> time that isn't a big concern for us though.
>
> /M
>
> --
> Magnus Therning                      OpenPGP: 0xAB4DFBA4
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
> --
>
> 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://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131015/0639385c/attachment-0001.htm>


More information about the CMake mailing list