Using CMake to generate Visual Studio C++ project files
CMake is actually pretty good for this. The key part was everyone on the Windows side has to remember to run CMake before loading in the solution, and everyone on our Mac side would have to remember to run it before make.
The hardest part was as a Windows developer making sure your structural changes were in the cmakelist.txt file and not in the solution or project files as those changes would probably get lost and even if not lost would not get transferred over to the Mac side who also needed them, and the Mac guys would need to remember not to modify the make file for the same reasons.
It just requires a little thought and patience, but there will be mistakes at first. But if you are using continuous integration on both sides then these will get shook out early, and people will eventually get in the habit.
Visual Studio 2017 - How to create a project from the source using CMake?
I'm not sure why you asked for details but...
Assuming you are using cmake 3.13 then you can do the following in a command shell:
cmake -G "Visual Studio 15 2017" -S path_to_source -B path_to_build
This will then create a solution file. Actually it creates a solution file for every project()
command that is issued in CMakeLists.txt
.
You can then open the solution file in Visual Studio
, and build the project as usual.
You don't even need to do this in the Visual Studio
GUI. After creating the initial project you can also issue the command:
cmake --build path_to_build
Which will kick off the build at the command line.
Now if your CMakeLists.txt
in path_to_source is using Linux specific libraries or gcc
specific compiler settings then the CMakeLists.txt
will have to get updated to the Windows equivalent.
The alternative is to start Visual Studio
and then use File->Open->CMake
and open the CMakeLists.txt
file in path_to_source. It'll then start to generate the project. But I prefer using the command line method.
Convert CMake.txt to .vcxproj file C++ Visual Studio project
This is what cmake
does, generates projects for almost any IDE or build manager.
So for VS 2017 it can be used like this:
cd "<path where CMakeLists.txt is located>"
mkdir build
cd build
cmake -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_GENERATOR_PLATFORM=x64 -G "Visual Studio 15 2017" ..
cmake --open .
how to use cmake to generate visual studio at specified build directory
lets say you have
Repository/CMakeLists.txt
Repository/srcs...
and you create a bin directory in Repository:
cd Repository
mkdir bin
cd bin
then you can do what you want:
cmake -G "Visual Studio 9 2008" ..
and it will work.
using cmake, build a visual studio project with dependencies, being able to debug also into the dependencies
I ended up modifying the dependencies so that they implement unique target names for documentation, but if built individually to create the original named target: DOCUMENTATION.
doxygen_add_docs(DOCUMENTATION_${PROJECT_NAME}
doc
src/component
)
if (NOT (TARGET DOCUMENTATION))
add_custom_target(DOCUMENTATION COMMENT "workaround for multi-dependencies project")
add_dependencies(DOCUMENTATION DOCUMENTATION_${PROJECT_NAME})
endif()
Related Topics
For Purposes of Ordering, Is Atomic Read-Modify-Write One Operation or Two
Assertion Failed (Size.Width>0 && Size.Height>0)
Clean C++ Granular Friend Equivalent? (Answer: Attorney-Client Idiom)
How to Do Static Linking of Libwinpthread-1.Dll in Mingw
Casting Pointer to Array (Int* to Int[2])
How to Make a Heterogeneous Boost::Map
Translating Python Dictionary to C++
Avoiding Denormal Values in C++
How to Avoid Static Member Function When Using Gsl with C++
How to Building Static Qt with Static Openssl
Reset Cuda Context After Exception
How to Convert from Int to Char*
Windows C++ Compiler with Full C++11 Support (Should Work with Qt)
Use Std::Fill to Populate Vector with Increasing Numbers