views:

237

answers:

2

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 project 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 ?

+1  A: 

This problem is driving us crazy too. A slight improvement is to set the INSTALL project as the default through the "Set as Startup Project" option in its context menu.

This seems so fundamental that there's got to be a better way.

Simeon Fitch
+1  A: 

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: http://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test/1307784#1307784

pkit