We are moving from hand-managed Visual Studio projects to cross platform cmake.
We used to open a solutions file, select a project as "Startup Target" and push Ctrl+F5 or F5 debug or run.
Now cmake has this install concept. It requires me to run the install target. But the install proj开发者_Python百科ect doesn't have any executables set so it can not be used to start with debugging.
If I set my executable project as a startup target, then install will not run, so I can not debug.
I am sure there is a better way of doing this.
Any ideas ?
You should only need to run the INSTALL target if you want to distribute your application. If you select a project that builds an executable (so it has a ADD_EXECUTABLE statement in the CMakeLists.txt file) it should run with F5 or Ctrl+F5.
It could be that you executable requires shared libraries which are build in a seperate directory. You can force all executables and libraries to be build in the same directory with the following CMake commands in your main CMakeLists.txt file.
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Library output path")
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Bin/${CMAKE_BUILD_TYPE} CACHE PATH "Executable output path")
If you want more control over the command that should be run when debugging have a look at this question: How to Set Path Environment Variable using CMake and Visual Studio to Run Test
精彩评论