summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-09-01 17:40:18 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2020-09-02 12:59:59 -0400
commita9fd3a107dc4bc34b8d2822b9153ee0ab9e02ea8 (patch)
tree9ca32f0f90fd36c8d3328b64278dcb390cf79bb0
parentf1199bdc96d255fbd10772b64d6ff1c64490bb57 (diff)
downloadcmake-a9fd3a107dc4bc34b8d2822b9153ee0ab9e02ea8.tar.gz
Ninja Multi-Config: Fix dependencies of utility targets
Fixes: #21118
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-clean-build-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-custom-ninja-check.cmake6
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake6
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake12
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake4
6 files changed, 32 insertions, 2 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index fce1b9b9e4..f11cd5055c 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1170,7 +1170,8 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
for (auto const& dep_target : this->GetTargetDirectDepends(target)) {
if (dep_target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
- (this->EnableCrossConfigBuild() && !dep_target.IsCross())) {
+ (target->GetType() != cmStateEnums::UTILITY &&
+ this->EnableCrossConfigBuild() && !dep_target.IsCross())) {
continue;
}
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-clean-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-clean-build-check.cmake
new file mode 100644
index 0000000000..a6eb08857c
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-clean-build-check.cmake
@@ -0,0 +1,3 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-custom-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-custom-ninja-check.cmake
new file mode 100644
index 0000000000..b142ed2672
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-custom-ninja-check.cmake
@@ -0,0 +1,6 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${TARGET_BYPRODUCTS_LeafCustom}
+ ${TARGET_BYPRODUCTS_RootCustom}
+ ${TARGET_FILE_RootExe_Release}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake
new file mode 100644
index 0000000000..3f5198388a
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake
@@ -0,0 +1,6 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${TARGET_FILE_LeafExe_Release}
+ ${TARGET_BYPRODUCTS_RootCustom}
+ ${TARGET_FILE_RootExe_Release}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
index b2b24e81a0..b6f11529fd 100644
--- a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
@@ -34,6 +34,16 @@ add_subdirectory(CustomCommandsAndTargetsSubdir)
create_targets(Top)
+add_executable(RootExe main.c)
+add_custom_target(RootCustom COMMAND ${CMAKE_COMMAND} -E touch Root.txt BYPRODUCTS Root.txt)
+add_executable(LeafExe main.c)
+add_custom_target(LeafCustom COMMAND ${CMAKE_COMMAND} -E touch Leaf.txt BYPRODUCTS Leaf.txt DEPENDS RootCustom RootExe)
+add_dependencies(LeafExe RootExe RootCustom)
+file(APPEND "${CMAKE_BINARY_DIR}/target_files_custom.cmake"
+"set(TARGET_BYPRODUCTS_LeafCustom [==[${CMAKE_CURRENT_BINARY_DIR}/Leaf.txt]==])
+set(TARGET_BYPRODUCTS_RootCustom [==[${CMAKE_CURRENT_BINARY_DIR}/Root.txt]==])
+")
+
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
-generate_output_files(TopPostBuild SubdirPostBuild)
+generate_output_files(TopPostBuild SubdirPostBuild RootExe LeafExe)
file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "include(\${CMAKE_CURRENT_LIST_DIR}/target_files_custom.cmake)\n")
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index 82489251af..fe32fb64e1 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -235,6 +235,10 @@ run_cmake_build(CustomCommandsAndTargets debug-in-release-graph-postbuild Releas
run_ninja(CustomCommandsAndTargets release-postbuild build-Release.ninja SubdirPostBuild)
run_cmake_build(CustomCommandsAndTargets debug-targetpostbuild Debug TopTargetPostBuild)
run_ninja(CustomCommandsAndTargets release-targetpostbuild build-Release.ninja SubdirTargetPostBuild)
+run_cmake_build(CustomCommandsAndTargets release-clean Release clean:all)
+run_ninja(CustomCommandsAndTargets release-leaf-custom build-Release.ninja Leaf.txt)
+run_cmake_build(CustomCommandsAndTargets release-clean Release clean:all)
+run_ninja(CustomCommandsAndTargets release-leaf-exe build-Release.ninja LeafExe)
unset(RunCMake_TEST_BINARY_DIR)