How do I change the startup project of a Visual Studio solution via CMake?

后端 未结 6 1503
刺人心
刺人心 2020-12-05 09:13

I am using CMake to generate Visual Studio projects. Everything works fine except one thing.

The startup project in the solution is always ALL_BUILD. Ho

6条回答
  •  离开以前
    2020-12-05 09:52

    Since Visual 2005, the configuration is stored in a file name projectname.vc(x)proj.user, which is plain xml.

    I don't know about a way to change the startup project, but you certainly can set ALL_BUILD to run the desired executable instead of displaying the stupid popup :

    create_default_target_launcher(
        your_desired_target_name
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/desired_path/"
        # or ${CMAKE_CURRENT_BINARY_DIR}, depending on your setup
    )
    

    This module is available on rpavlik's github. You simply need to add this in your topmost CMakeLists.txt :

    list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-1c73e35") # or whichever path you put the module in.
    include(CreateLaunchers)
    

    Examples available here.

提交回复
热议问题