From b57b7d8e55f5380a70c98dd5feeb01c40325f403 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 20 Apr 2017 15:55:34 -0400 Subject: Ninja: Order Fortran dyndep file generation explicitly Each target's dyndep file generation depends on loading information generated by the same step in its dependencies. Add an explicit ordering dependency to ensure the needed information is available. Without the explicit ordering dependency we were abusing the more general target ordering rules through the preprocessor rules generating the `.ddi` files used as input to dyndep file generation. --- Source/cmNinjaTargetGenerator.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b008158..a34ff3f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -767,6 +767,17 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() ddOutputs.push_back(this->GetDyndepFilePath("Fortran")); + // Make sure dyndep files for all our dependencies have already + // been generated so that the 'FortranModules.json' files they + // produced as side-effects are available for us to read. + // Ideally we should depend on the 'FortranModules.json' files + // from our dependencies directly, but we don't know which of + // our dependencies produces them. Fixing this will require + // refactoring the Ninja generator to generate targets in + // dependency order so that we can collect the needed information. + this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget, + ddOrderOnlyDeps); + this->GetGlobalGenerator()->WriteBuild( this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts, ddExplicitDeps, ddImplicitDeps, ddOrderOnlyDeps, ddVars); -- cgit v0.12 From e9827eba686c431e393cea6dcd71fe25f1eda98f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 31 Jan 2017 13:07:24 -0500 Subject: ninja: describe the intermediate order depends target better This is only used for compiled objects, so indicate it as such. --- Source/cmNinjaTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a34ff3f..7fbb2fc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -117,7 +117,7 @@ bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget() { - return "cmake_order_depends_target_" + this->GetTargetName(); + return "cmake_object_order_depends_target_" + this->GetTargetName(); } // TODO: Most of the code is picked up from -- cgit v0.12 From 7f947b602f00ea94161c98b2887479e445d9bc92 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 18 Apr 2017 14:11:40 -0400 Subject: ninja: remove duplicate order-only dependencies --- Source/cmNinjaTargetGenerator.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 7fbb2fc..daad3fc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -737,6 +737,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } + std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end()); + orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()), + orderOnlyDeps.end()); + if (!orderOnlyDeps.empty()) { cmNinjaDeps orderOnlyTarget; orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); -- cgit v0.12 From 01c5bb9551ff0322f2cb4d5439a2ab9a94c87815 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 18 Apr 2017 14:52:44 -0400 Subject: RunCMake.Ninja: support passing arguments when running ninja --- Tests/RunCMake/Ninja/RunCMakeTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 7b4e51e..063a6d1 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -73,7 +73,7 @@ run_SubDir() function(run_ninja dir) execute_process( - COMMAND "${RunCMake_MAKE_PROGRAM}" + COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN} WORKING_DIRECTORY "${dir}" OUTPUT_VARIABLE ninja_stdout ERROR_VARIABLE ninja_stderr -- cgit v0.12 From adf60b28384025d5b83c2df5a66f2190753e2695 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 17 Apr 2017 16:24:44 -0400 Subject: ninja: break unnecessary target dependencies Previously, given two libraries, X and Y where X depends on Y, all object compilations of X would require the Y library to have been linked before being compiled. This is not necessary and can instead be loosened such that object compilations of X only depend on the order-only dependencies of Y to be completed. This is to ensure that generated sources, headers, custom commands, etc. are completed before X starts to compile its objects. This should help build performance in projects with many libraries which cause a deep library dependency chain. Previously, a library at the bottom would not start compilation until after all other libraries completed, but now only its link step needs to wait and its compilation jobs can be run in parallel with other tasks. Fixes: #15555 --- Source/cmGlobalNinjaGenerator.cxx | 29 ++++++++++++++++++++++----- Source/cmGlobalNinjaGenerator.h | 10 +++++---- Source/cmLocalNinjaGenerator.cxx | 6 ++++-- Source/cmLocalNinjaGenerator.h | 4 +++- Source/cmNinjaTargetGenerator.cxx | 18 ++++++++--------- Source/cmNinjaTargetGenerator.h | 3 +-- Source/cmNinjaTypes.h | 6 ++++++ Tests/RunCMake/CMakeLists.txt | 4 ++++ Tests/RunCMake/Ninja/LooseObjectDepends.cmake | 26 ++++++++++++++++++++++++ Tests/RunCMake/Ninja/RunCMakeTest.cmake | 17 ++++++++++++++++ Tests/RunCMake/Ninja/dep.c | 4 ++++ Tests/RunCMake/Ninja/top.c | 7 +++++++ 12 files changed, 110 insertions(+), 24 deletions(-) create mode 100644 Tests/RunCMake/Ninja/LooseObjectDepends.cmake create mode 100644 Tests/RunCMake/Ninja/dep.c create mode 100644 Tests/RunCMake/Ninja/top.c diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e61cbd9..1a77d7c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -966,8 +966,14 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() } } +std::string OrderDependsTargetForTarget(cmGeneratorTarget const* target) +{ + return "cmake_object_order_depends_target_" + target->GetName(); +} + void cmGlobalNinjaGenerator::AppendTargetOutputs( - cmGeneratorTarget const* target, cmNinjaDeps& outputs) + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { std::string configName = target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -979,15 +985,27 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( bool realname = target->IsFrameworkOnApple(); switch (target->GetType()) { - case cmStateEnums::EXECUTABLE: case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { + if (depends == DependOnTargetOrdering) { + outputs.push_back(OrderDependsTargetForTarget(target)); + break; + } + } + // FALLTHROUGH + case cmStateEnums::EXECUTABLE: { outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath( configName, cmStateEnums::RuntimeBinaryArtifact, realname))); break; } - case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { + if (depends == DependOnTargetOrdering) { + outputs.push_back(OrderDependsTargetForTarget(target)); + break; + } + } + // FALLTHROUGH case cmStateEnums::GLOBAL_TARGET: case cmStateEnums::UTILITY: { std::string path = @@ -1003,7 +1021,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( } void cmGlobalNinjaGenerator::AppendTargetDepends( - cmGeneratorTarget const* target, cmNinjaDeps& outputs) + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { // These depend only on other CMake-provided targets, e.g. "all". @@ -1023,7 +1042,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - this->AppendTargetOutputs(*i, outs); + this->AppendTargetOutputs(*i, outs, depends); } std::sort(outs.begin(), outs.end()); outputs.insert(outputs.end(), outs.begin(), outs.end()); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e06afb0..b1d6155 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -316,10 +316,12 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmGeneratorTarget const* target, - cmNinjaDeps& outputs); - void AppendTargetDepends(cmGeneratorTarget const* target, - cmNinjaDeps& outputs); + void AppendTargetOutputs( + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); + void AppendTargetDepends( + cmGeneratorTarget const* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); void AppendTargetDependsClosure(cmGeneratorTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmGeneratorTarget* target); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c2d9d57..9d88e35 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -278,9 +278,11 @@ void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target, } void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target, - cmNinjaDeps& outputs) + cmNinjaDeps& outputs, + cmNinjaTargetDepends depends) { - this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); + this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs, + depends); } void cmLocalNinjaGenerator::AppendCustomCommandDeps( diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index fda4578..a45e018 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -63,7 +63,9 @@ public: std::string BuildCommandLine(const std::vector& cmdLines); void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs); + void AppendTargetDepends( + cmGeneratorTarget* target, cmNinjaDeps& outputs, + cmNinjaTargetDepends depends = DependOnTargetArtifact); void AddCustomCommandTarget(cmCustomCommand const* cc, cmGeneratorTarget* target); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index daad3fc..2c14a3e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -715,8 +715,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } cmNinjaDeps orderOnlyDeps; - this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget, - orderOnlyDeps); + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering); // Add order-only dependencies on other files associated with the target. orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(), @@ -741,7 +741,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()), orderOnlyDeps.end()); - if (!orderOnlyDeps.empty()) { + { cmNinjaDeps orderOnlyTarget; orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); this->GetGlobalGenerator()->WritePhonyBuild( @@ -754,7 +754,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() for (std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty()); + this->WriteObjectBuildStatement(*si); } if (!this->DDIFiles.empty()) { @@ -779,8 +779,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() // our dependencies produces them. Fixing this will require // refactoring the Ninja generator to generate targets in // dependency order so that we can collect the needed information. - this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget, - ddOrderOnlyDeps); + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, ddOrderOnlyDeps, DependOnTargetArtifact); this->GetGlobalGenerator()->WriteBuild( this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts, @@ -791,7 +791,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } void cmNinjaTargetGenerator::WriteObjectBuildStatement( - cmSourceFile const* source, bool writeOrderDependsTargetForTarget) + cmSourceFile const* source) { std::string const language = source->GetLanguage(); std::string const sourceFileName = @@ -842,9 +842,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } cmNinjaDeps orderOnlyDeps; - if (writeOrderDependsTargetForTarget) { - orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); - } + orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); // If the source file is GENERATED and does not have a custom command // (either attached to this source file or another one), assume that one of diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 9ce8651..5eb7a9a 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -119,8 +119,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile const* source, - bool writeOrderDependsTargetForTarget); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteTargetDependInfo(std::string const& lang); void ExportObjectCompileCommand( diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index b4af70e..ec435d9 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -9,6 +9,12 @@ #include #include +enum cmNinjaTargetDepends +{ + DependOnTargetArtifact, + DependOnTargetOrdering +}; + typedef std::vector cmNinjaDeps; typedef std::map cmNinjaVars; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 32c4be8..21e6259 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -119,6 +119,10 @@ if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make) endif() if(CMAKE_GENERATOR STREQUAL "Ninja") + set(Ninja_ARGS + -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION} + -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} + -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}) add_RunCMake_test(Ninja) endif() add_RunCMake_test(CTest) diff --git a/Tests/RunCMake/Ninja/LooseObjectDepends.cmake b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake new file mode 100644 index 0000000..360c7ba --- /dev/null +++ b/Tests/RunCMake/Ninja/LooseObjectDepends.cmake @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.8) +project(LooseObjectDepends C) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command.h" + COMMAND "${CMAKE_COMMAND}" -E touch + "${CMAKE_CURRENT_BINARY_DIR}/command.h" + COMMENT "Creating command.h") +add_custom_target(create-command.h + DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/command.h") + +add_custom_target(create-target.h + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/target.h" + COMMAND "${CMAKE_COMMAND}" -E touch + "${CMAKE_CURRENT_BINARY_DIR}/target.h" + COMMENT "Creating target.h") + +add_library(dep SHARED dep.c) +add_dependencies(dep create-command.h create-target.h) +target_include_directories(dep + PUBLIC + "${CMAKE_CURRENT_BINARY_DIR}") + +add_library(top top.c) +target_link_libraries(top PRIVATE dep) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 063a6d1..fb7798d 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -95,6 +95,23 @@ ${ninja_stderr} endif() endfunction(run_ninja) +function (run_LooseObjectDepends) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LooseObjectDepends-build) + run_cmake(LooseObjectDepends) + run_ninja("${RunCMake_TEST_BINARY_DIR}" "CMakeFiles/top.dir/top.c${CMAKE_C_OUTPUT_EXTENSION}") + if (EXISTS "${RunCMake_TEST_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dep${CMAKE_SHARED_LIBRARY_SUFFIX}") + message(FATAL_ERROR + "The `dep` library was created when requesting an object file to be " + "built; this should no longer be necessary.") + endif () + if (EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/dep.dir/dep.c${CMAKE_C_OUTPUT_EXTENSION}") + message(FATAL_ERROR + "The `dep.c` object file was created when requesting an object file to " + "be built; this should no longer be necessary.") + endif () +endfunction () +run_LooseObjectDepends() + function(sleep delay) execute_process( COMMAND ${CMAKE_COMMAND} -E sleep ${delay} diff --git a/Tests/RunCMake/Ninja/dep.c b/Tests/RunCMake/Ninja/dep.c new file mode 100644 index 0000000..728f031 --- /dev/null +++ b/Tests/RunCMake/Ninja/dep.c @@ -0,0 +1,4 @@ +int dep() +{ + return 0; +} diff --git a/Tests/RunCMake/Ninja/top.c b/Tests/RunCMake/Ninja/top.c new file mode 100644 index 0000000..4a88eb2 --- /dev/null +++ b/Tests/RunCMake/Ninja/top.c @@ -0,0 +1,7 @@ +#include "command.h" +#include "target.h" + +int top() +{ + return 0; +} -- cgit v0.12 From 664591ce59792f6508d6376aca916ab0f02d213f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 18 Apr 2017 15:05:35 -0400 Subject: RunCMake.Ninja: add a test for assumed sources This is a dark corner of the Ninja generator. It should be fixed in the future, but add a test which shows its behaviors. --- Tests/RunCMake/Ninja/AssumedSources.cmake | 20 ++++++++++++++++++++ Tests/RunCMake/Ninja/RunCMakeTest.cmake | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Tests/RunCMake/Ninja/AssumedSources.cmake diff --git a/Tests/RunCMake/Ninja/AssumedSources.cmake b/Tests/RunCMake/Ninja/AssumedSources.cmake new file mode 100644 index 0000000..5fb0219 --- /dev/null +++ b/Tests/RunCMake/Ninja/AssumedSources.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.8) +project(AssumedSources) + +set_source_files_properties( + "${CMAKE_CURRENT_BINARY_DIR}/target.c" + "${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c" + PROPERTIES GENERATED 1) + +add_executable(working + "${CMAKE_CURRENT_BINARY_DIR}/target.c" + "${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c") + +add_custom_target( + gen-target.c ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/dep.c" "${CMAKE_CURRENT_BINARY_DIR}/target.c") +add_custom_target( + gen-target-no-depends.c ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/dep.c" "${CMAKE_CURRENT_BINARY_DIR}/target-no-depends.c") + +add_dependencies(working gen-target.c) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index fb7798d..8c3bc20 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -112,6 +112,22 @@ function (run_LooseObjectDepends) endfunction () run_LooseObjectDepends() +function (run_AssumedSources) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AssumedSources-build) + run_cmake(AssumedSources) + run_ninja("${RunCMake_TEST_BINARY_DIR}" "target.c") + if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/target.c") + message(FATAL_ERROR + "Dependencies for an assumed source did not hook up properly for 'target.c'.") + endif () + run_ninja("${RunCMake_TEST_BINARY_DIR}" "target-no-depends.c") + if (EXISTS "${RunCMake_TEST_BINARY_DIR}/target-no-depends.c") + message(FATAL_ERROR + "Dependencies for an assumed source were magically hooked up for 'target-no-depends.c'.") + endif () +endfunction () +run_AssumedSources() + function(sleep delay) execute_process( COMMAND ${CMAKE_COMMAND} -E sleep ${delay} -- cgit v0.12 From d96e5d9a19d613de108ab399663f76a8dd964172 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 18 Apr 2017 15:12:32 -0400 Subject: Tests: use BYPRODUCTS in the CustomCommandWorkingDirectory test This was inadvertently testing the assumed sources behavior in Ninja (no other test seems to exercise it). There is now a test explicitly testing it in `RunCMake.Ninja`, so fix this test to work properly regardless of the assumed sources behavior. --- Help/release/dev/ninja-loosen-object-deps.rst | 8 ++++++++ Tests/CustomCommandWorkingDirectory/CMakeLists.txt | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 Help/release/dev/ninja-loosen-object-deps.rst diff --git a/Help/release/dev/ninja-loosen-object-deps.rst b/Help/release/dev/ninja-loosen-object-deps.rst new file mode 100644 index 0000000..c47fb93 --- /dev/null +++ b/Help/release/dev/ninja-loosen-object-deps.rst @@ -0,0 +1,8 @@ +ninja-loosen-object-deps +------------------------ + +* The :generator:`Ninja` generator has loosened dependencies on object + compilation to depend on the custom targets and commands of dependent + libraries instead of the libraries themselves. This helps projects with deep + dependency graphs to be blocked only on their link steps at the deeper + levels rather than also blocking object compilation on dependent link steps. diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt index f917cd7..4975feb 100644 --- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt +++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(working "${TestWorkingDir_BINARY_DIR}/working.c" add_custom_target( Custom ALL COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget.c" + BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget.c" WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}" ) @@ -36,6 +37,7 @@ add_executable(working2 working2.c ${TestWorkingDir_BINARY_DIR}/customTarget2.c) add_custom_target( Custom2 ALL COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${TestWorkingDir_SOURCE_DIR}/customTarget.c ../customTarget2.c + BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget2.c" WORKING_DIRECTORY work/ # Relative to build tree, trailing slash ) -- cgit v0.12