Is there a generic way for disabling executable targets in cmake

前端 未结 1 1576
故里飘歌
故里飘歌 2021-01-07 23:20

With our CMake build system I build some libraries and some executables. The build products are all output to a specific folder.

Now, the problem is I have a VS2010

相关标签:
1条回答
  • 2021-01-07 23:40

    CMake targets have two properties which control if a target is built by default. The first one is EXCLUDE_FROM_ALL. It indicates if the target is excluded from the default build target. For Makefile generators, typing make will not trigger a build of a target whose EXCLUDE_FROM_ALL property is set to 1.

    The other one is EXCLUDE_FROM_DEFAULT_BUILD and only applies to Visual Studio generators. If it is set to 1, the target will not be part of the default build when you invoke the "Build Solution" menu command.

    You could set the values of both properties for executable targets depending on the option BUILD_EXECUTABLES:

    if (NOT BUILD_EXECUTABLES)
       set_target_properties(exe1 exe2 PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
    endif()
    
    0 讨论(0)
提交回复
热议问题