summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-09-17 13:49:52 -0400
committerKyle Edwards <kyle.edwards@kitware.com>2020-09-17 15:46:57 -0400
commit23fe4b861f5cd2c513981b04bee7c36b467ac100 (patch)
tree6cfffca130f12e87ea14d2c4539d65585512790c
parent314039ba45ad4f7779e2c4df46dab3fac3703194 (diff)
downloadcmake-23fe4b861f5cd2c513981b04bee7c36b467ac100.tar.gz
Ninja Multi-Config: Fix dependencies of custom commands
a9fd3a10 addressed the scenario where the depending target is a utility target, but not the scenario where the dependent target is a utility target. Account for this scenario. Also add a Qt-specific test case. Fixes: #21118
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx1
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-byproduct-ninja-check.cmake5
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake1
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake14
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt7
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake7
6 files changed, 28 insertions, 7 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index f11cd5055c..04155e09d9 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1171,6 +1171,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
for (auto const& dep_target : this->GetTargetDirectDepends(target)) {
if (dep_target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
(target->GetType() != cmStateEnums::UTILITY &&
+ dep_target->GetType() != cmStateEnums::UTILITY &&
this->EnableCrossConfigBuild() && !dep_target.IsCross())) {
continue;
}
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-byproduct-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-byproduct-ninja-check.cmake
new file mode 100644
index 0000000000..b2d67b47db
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-byproduct-ninja-check.cmake
@@ -0,0 +1,5 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${TARGET_BYPRODUCTS_LeafExe}
+ ${TARGET_BYPRODUCTS_RootCustom}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake
index 3f5198388a..e29dab678a 100644
--- a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake
@@ -1,6 +1,7 @@
check_files("${RunCMake_TEST_BINARY_DIR}"
INCLUDE
${TARGET_FILE_LeafExe_Release}
+ ${TARGET_BYPRODUCTS_LeafExe}
${TARGET_BYPRODUCTS_RootCustom}
${TARGET_FILE_RootExe_Release}
)
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
index b6f11529fd..7bed090905 100644
--- a/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake
@@ -35,13 +35,15 @@ 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)
+add_custom_target(RootCustom COMMAND ${CMAKE_COMMAND} -E touch RootCustom.txt BYPRODUCTS RootCustom.txt)
+add_custom_command(OUTPUT main.c COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.c ${CMAKE_CURRENT_BINARY_DIR}/main.c DEPENDS RootCustom)
+add_executable(LeafExe ${CMAKE_CURRENT_BINARY_DIR}/main.c)
+add_custom_target(LeafCustom COMMAND ${CMAKE_COMMAND} -E touch LeafCustom.txt BYPRODUCTS LeafCustom.txt DEPENDS RootCustom RootExe)
+add_dependencies(LeafExe RootExe)
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]==])
+"set(TARGET_BYPRODUCTS_LeafCustom [==[${CMAKE_CURRENT_BINARY_DIR}/LeafCustom.txt]==])
+set(TARGET_BYPRODUCTS_LeafExe [==[${CMAKE_CURRENT_BINARY_DIR}/main.c]==])
+set(TARGET_BYPRODUCTS_RootCustom [==[${CMAKE_CURRENT_BINARY_DIR}/RootCustom.txt]==])
")
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt
new file mode 100644
index 0000000000..85d5fdc75f
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt
@@ -0,0 +1,7 @@
+ input: CUSTOM_COMMAND(
+ [^
+]*)*
+ \|\| exe_autogen_timestamp_deps:Debug(
+ [^
+]*)*
+ outputs:
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index fe32fb64e1..0aef2b9f10 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -236,9 +236,11 @@ run_ninja(CustomCommandsAndTargets release-postbuild build-Release.ninja SubdirP
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_ninja(CustomCommandsAndTargets release-leaf-custom build-Release.ninja LeafCustom.txt)
run_cmake_build(CustomCommandsAndTargets release-clean Release clean:all)
run_ninja(CustomCommandsAndTargets release-leaf-exe build-Release.ninja LeafExe)
+run_cmake_build(CustomCommandsAndTargets release-clean Release clean:all)
+run_ninja(CustomCommandsAndTargets release-leaf-byproduct build-Release.ninja main.c)
unset(RunCMake_TEST_BINARY_DIR)
@@ -309,4 +311,7 @@ if(CMake_TEST_Qt5)
unset(RunCMake_TEST_OPTIONS)
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
run_cmake_build(Qt5 debug-in-release-graph Release exe:Debug)
+ if(CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0)
+ run_ninja(Qt5 automoc-check build-Debug.ninja -t query exe_autogen/timestamp)
+ endif()
endif()