Disabling a Visual Studio project for building using cmake

I am creating a VS2010 solution with several projects (currently 4, there will be up to 10-20 at the end). I want one of them to build; the rest should be disabled. I can do this manually by going into the configuration manager and unchecking the boxes that I don't want, but obviously this is not a good solution.

Is there something I can add to the CMakeLists.txt file for a project that will force it to do this? Search through documents, google and SO yielded nothing.

only bam projectshould be built

Update: here is my root CMakeLists.txt in case this helps:

cmake_minimum_required(VERSION 2.8) add_definitions(-DCOMPILER_MSVC) project (PDEngine) set(LINKER_LANGUAGE CXX) add_subdirectory (units/platform) add_subdirectory (units/render_api) add_subdirectory (units/memory) add_subdirectory (units/game) set(custom_exe "${CMAKE_CURRENT_BINARY_DIR}/units/Platform/Debug/Platform.lib2") add_custom_command(OUTPUT ${custom_exe} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/local/msvc/bam.bat -j $ENV{NUMBER_OF_PROCESSORS} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/local/msvc/bam.bat ) #add_custom_command(OUTPUT ${custom_exe_clean} #COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/local/msvc/bam.bat -c #DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/local/msvc/bam.bat #) add_custom_target(bam ALL DEPENDS ${custom_exe}) #add_custom_target(bamclean ALL DEPENDS ${custom_exe_clean}}) 

(The bam.bat material is based on the answer I got here: How do I configure CMake so that the VS solution uses a specific build command line? )

And here is CMakeLists.txt for the platform project:

 cmake_minimum_required (VERSION 2.8) project (Platform) set (COMPILER_MSVC 1) include_directories(${Platform_SOURCE_DIR}/include) file(GLOB Project_HEADERS ${Platform_SOURCE_DIR}/include/platform/*.h) source_group("Headers" FILES ${Project_HEADERS}) add_library(Platform STATIC EXCLUDE_FROM_ALL src/*.cpp ${Project_HEADERS}) 
+6
source share
2 answers

So, if you want to do something by default, you can remove it from the "ALL" target (which is displayed as ALL_BUILD in Visual Studio). How do you do this, with the target property EXCLUDE_FROM_ALL or passing EXCLUDE_FROM_ALL to add_executable and add_library. (The default custom targets are EXCLUDE_FROM_ALL, so to do the opposite, you add ALL to the add_custom_target arguments).

Then all your goals will be displayed, but when you click "build solution", only those you want will be created. Others can be created by right-clicking and choosing Build, for example, an embedded project / goal INSTALL.

+2
source

For this purpose, the EXCLUDE_FROM_DEFAULT_BUILD target property EXCLUDE_FROM_DEFAULT_BUILD .

See fooobar.com/questions/536870 / ....

+1
source

Source: https://habr.com/ru/post/901354/


All Articles