Using CMake to generate Visual Studio C++ project files

前端 未结 8 1378
花落未央
花落未央 2020-12-02 05:48

I am working on an open source C++ project, for code that compiles on Linux and Windows. I use CMake to build the code on Linux. For ease of development setup and political

8条回答
  •  既然无缘
    2020-12-02 06:04

    CMake can generate really nice Visual Studio .projs/.slns, but there is always the problem with the need to modify the .cmake files rather than .proj/.sln. As it is now, we are dealing with it as follows:

    1. All source files go to /src and files visible in Visual Studio are just "links" to them defined in .filter.
    2. Programmer adds/deletes files remembering to work on the defined /src directory, not the default project's one.
    3. When he's done, he run a script that "refreshes" the respective .cmake files.
    4. He checks if the code can be built in the recreated environment.
    5. He commits the code.

    At first we were a little afraid of how it will turn out, but the workflow works really well and with nice diff visible before each commit, everyone can easily see if his changes were correctly mapped in .cmake files.

    One more important thing to know about is the lack of support (afaik) for "Solution Configurations" in CMake. As it stands, you have to generate two directories with projects/solutions - one for each build type (debug, release, etc.). There is no direct support for more sophisticated features - in other words: switching between configurations won't give you what you might expect.

提交回复
热议问题