I have a problem on building specific Visual Studio Projects from a CMake source tree. Immagine we have multiple targets in various subdirectories. In one sub-directory we initiate a new project (and solution). The projects in this project targets should be part of ALL_BUILD, but not in the parent ALL_BUILD.
In short:
project(Main)
add_executable(MainApplication ...)
target_link_libraries(MainApplication PRIVATE Library_A)
add_subdirectory(Library_A)
add_library(Library_A STATIC ...)
add_subdirectory(Other_Related_Stuff_Using_MainApplication)
project(OtherRelatedStuff)
add_custom_target(OtherTarget ... DEPENDS MainApplication)
Now with a Visual Studio generator we get two Solution Files. That is right and correct. In both solutions we have these three projects (as OtherReleatedStuff depends on MainApplication beeing built and OtherRelatedStuff is part of the Main-Project).
Now: ALL_BUILD builds all projects.
When I set
set_target_properties(OtherTarget PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
in both solutions OtherTarget is disabled.
What I would like to do is:
Solution 1:
In Main.Sln
there should be not OtherTarget. In OtherRelatedStuff.sln there could be MainApplication, but should not build. Maybe there shouldn't be a MainApplication as well.
Solution 2:
In Main.Sln
, OtherTarget should never build (excluded from build). In OtherRelatedStuff.sln, OtherTarget should build, but the dependencies don't or should be even visible.
Is there a solution for it?