3

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 ?

Paul
  • 2,474
  • 7
  • 33
  • 48
  • 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. – metasim Apr 14 '10 at 15:15

1 Answers1

5

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

Community
  • 1
  • 1
pkit
  • 7,993
  • 6
  • 36
  • 36
  • 1
    Is this still the recommended solution for the problem or has cmake been extended with a built-in solution in the meantime? – Knitschi Jul 20 '17 at 14:55