diff options
author | Brad King <brad.king@kitware.com> | 2014-06-12 10:36:10 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-06-12 11:14:06 -0400 |
commit | 790e167718bff5660e9023f627df0413504fb207 (patch) | |
tree | 77b8523cd5123ba95064aa3448a74adb00846234 /Tests | |
parent | 5fba44cf41312a64b1cc661d4015ba16ac9f2af8 (diff) | |
download | cmake-790e167718bff5660e9023f627df0413504fb207.tar.gz |
VS: Fix subproject .sln dependencies on custom targets
Each project listed in a .sln must be marked (or not) as part of the
"default build" for each configuration. For targets created by the
add_custom_target() command we add them to the default build if they
are not excluded in some way or if another target depends on them.
In the top-level .sln, a custom target is excluded if it is not
created with the ALL option to add_custom_target. In subdirectory
.sln files, a target may also be excluded if it is not within the
directory and is brought into the solution only due to a dependency
from another target in the solution.
Fix the "IsPartOfDefaultBuild" and "IsDependedOn" methods to check
every target to be included in the .sln for a dependency on the
custom target. Otherwise transitive dependencies through targets
not in the current subdirectory will not be considered.
Extend the SubProject test with a custom target to cover this case.
Reported-by: William Deurwaarder <William.Deurwaarder@tomtom.com>
Reported-by: Dirk Steenpass <dirk.steenpass@gmail.com>
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/SubProject/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/SubProject/bar.cxx | 5 | ||||
-rw-r--r-- | Tests/SubProject/gen.cxx.in | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/Tests/SubProject/CMakeLists.txt b/Tests/SubProject/CMakeLists.txt index b669621df9..b2bada9110 100644 --- a/Tests/SubProject/CMakeLists.txt +++ b/Tests/SubProject/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required (VERSION 2.6) project(SubProject) -message("${CMAKE_IMPORT_LIBRARY_SUFFIX}") +file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/gen.cxx) # require generation +add_custom_command( + OUTPUT gen.cxx + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen.cxx.in + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/gen.cxx.in gen.cxx + ) +add_custom_target(gen DEPENDS gen.cxx) add_library(bar bar.cxx) +target_include_directories(bar PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +add_dependencies(bar gen) add_executable(car car.cxx) add_subdirectory(foo) diff --git a/Tests/SubProject/bar.cxx b/Tests/SubProject/bar.cxx index c3f6a181ad..c8b8743560 100644 --- a/Tests/SubProject/bar.cxx +++ b/Tests/SubProject/bar.cxx @@ -1,4 +1 @@ -int bar() -{ - return 10; -} +#include "gen.cxx" diff --git a/Tests/SubProject/gen.cxx.in b/Tests/SubProject/gen.cxx.in new file mode 100644 index 0000000000..c3f6a181ad --- /dev/null +++ b/Tests/SubProject/gen.cxx.in @@ -0,0 +1,4 @@ +int bar() +{ + return 10; +} |