From c35d1927a58366c56beb320835eb9366d0dccd70 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Sep 2020 16:58:58 -0400 Subject: Tests: Pass additional Qt information to Ninja and NMC tests --- Tests/RunCMake/CMakeLists.txt | 4 ++-- Tests/RunCMake/Ninja/RunCMakeTest.cmake | 1 + Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 470f302..ec4c7b5 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -143,14 +143,14 @@ if(CMAKE_GENERATOR MATCHES "Ninja") list(APPEND Ninja_ARGS -DTEST_Fortran=1) endif() if(CMake_TEST_Qt5 AND Qt5Core_FOUND) - list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) + list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DQt5Core_DIR=${Qt5Core_DIR} -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) endif() add_RunCMake_test(Ninja) set(NinjaMultiConfig_ARGS -DCYGWIN=${CYGWIN} ) if(CMake_TEST_Qt5 AND Qt5Core_FOUND) - list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_Qt5=1) + list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_Qt5=1 -DQt5Core_DIR=${Qt5Core_DIR} -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) endif() if(DEFINED CMake_TEST_CUDA) list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index d43023b..e6f86a1 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -327,6 +327,7 @@ run_ChangeBuildType() function(run_Qt5AutoMocDeps) if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build) + set(RunCMake_TEST_OPTIONS "-DQt5Core_DIR=${Qt5Core_DIR}") run_cmake(Qt5AutoMocDeps) unset(RunCMake_TEST_OPTIONS) # Build the project. diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 76b488e..8248925 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -300,7 +300,7 @@ endif() if(CMake_TEST_Qt5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") + set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all" "-DQt5Core_DIR=${Qt5Core_DIR}") run_cmake_configure(Qt5) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) -- cgit v0.12 From 657047cd24a4452e755522c84700ca490a076373 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 2 Sep 2020 09:42:26 -0400 Subject: Ninja Multi-Config: Fix clean:all target --- Source/cmGlobalNinjaGenerator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 843b0f4..fce1b9b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1863,6 +1863,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) byproducts.push_back( this->BuildAlias(GetByproductsForCleanTargetName(), config)); } + byproducts.emplace_back(GetByproductsForCleanTargetName()); build.Variables["TARGETS"] = cmJoin(byproducts, " "); for (auto const& fileConfig : configs) { -- cgit v0.12 From f1199bdc96d255fbd10772b64d6ff1c64490bb57 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 2 Sep 2020 10:15:24 -0400 Subject: Ninja Multi-Config: Fix cleaning of utility targets with commands --- Source/cmNinjaUtilityTargetGenerator.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 8d863c3..c964bc1 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -100,6 +100,8 @@ void cmNinjaUtilityTargetGenerator::Generate(const std::string& config) if (genTarget->Target->GetType() != cmStateEnums::GLOBAL_TARGET) { lg->AppendTargetOutputs(genTarget, gg->GetByproductsForCleanTarget(), config); + std::copy(util_outputs.begin(), util_outputs.end(), + std::back_inserter(gg->GetByproductsForCleanTarget())); } lg->AppendTargetDepends(genTarget, deps, config, config); -- cgit v0.12 From a9fd3a107dc4bc34b8d2822b9153ee0ab9e02ea8 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Sep 2020 17:40:18 -0400 Subject: Ninja Multi-Config: Fix dependencies of utility targets Fixes: #21118 --- Source/cmGlobalNinjaGenerator.cxx | 3 ++- .../CustomCommandsAndTargets-release-clean-build-check.cmake | 3 +++ ...mCommandsAndTargets-release-leaf-custom-ninja-check.cmake | 6 ++++++ ...stomCommandsAndTargets-release-leaf-exe-ninja-check.cmake | 6 ++++++ .../RunCMake/NinjaMultiConfig/CustomCommandsAndTargets.cmake | 12 +++++++++++- Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake | 4 ++++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-clean-build-check.cmake create mode 100644 Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-custom-ninja-check.cmake create mode 100644 Tests/RunCMake/NinjaMultiConfig/CustomCommandsAndTargets-release-leaf-exe-ninja-check.cmake diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index fce1b9b..f11cd50 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 0000000..a6eb088 --- /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 0000000..b142ed2 --- /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 0000000..3f51983 --- /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 b2b24e8..b6f1152 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 8248925..fe32fb6 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) -- cgit v0.12