Ninja: Add order-only dependencies to link commands (#14728)

A library or executable target that consists only of a reference to an
object library may have no sources to compile or custom commands to run.
The command in the target is the link (or archive) command.  Add missing
order-only dependencies to link commands so that target ordering
dependencies are satisfied for it without depending on an intermediate
compilation rule.

Extend the ObjectLibrary test to cover this case.

Co-Author: Brad King <brad.king@kitware.com>
This commit is contained in:
Ben Boeckel authored and Brad King committed 2014-07-01 10:14:28 -04:00
1 parent 623123aaa0
commit ac8879ce91
2 files changed
+12 -1

No files matched your search

+6 -1
View File
@@ -608,6 +608,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string(cmake::GetCMakeFilesDirectoryPostSlash()) std::string(cmake::GetCMakeFilesDirectoryPostSlash())
+ target.GetName() + ".rsp"; + target.GetName() + ".rsp";
// Gather order-only dependencies.
cmNinjaDeps orderOnlyDeps;
this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(),
orderOnlyDeps);
// Write the build statement for this target. // Write the build statement for this target.
globalGen.WriteBuild(this->GetBuildFileStream(), globalGen.WriteBuild(this->GetBuildFileStream(),
comment.str(), comment.str(),
@@ -615,7 +620,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
outputs, outputs,
explicitDeps, explicitDeps,
implicitDeps, implicitDeps,
emptyDeps, orderOnlyDeps,
vars, vars,
rspfile, rspfile,
commandLineLengthLimit); commandLineLengthLimit);
+6
View File
@@ -59,4 +59,10 @@ add_executable(UseABinternal ${dummy}
$<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B> $<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>
) )
# Test target-level dependencies of executable without sources.
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/UseABinternalDep.cmake)
add_custom_target(UseABinternalDep COMMAND ${CMAKE_COMMAND} -E touch UseABinternalDep.cmake)
add_custom_command(TARGET UseABinternal POST_BUILD COMMAND ${CMAKE_COMMAND} -P UseABinternalDep.cmake)
add_dependencies(UseABinternal UseABinternalDep)
add_subdirectory(ExportLanguages) add_subdirectory(ExportLanguages)