From 592644c42c58312aadf1fd1b28e95c7f0fbbb2f8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Nov 2014 13:19:13 -0500 Subject: Tests/BuildDepends: Drop unneeded help for Ninja The extra post-modification invocations of 'ninja' does not seem to be needed anymore for the BuildDepends test to pass. --- Tests/BuildDepends/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 8df331e..6209bb8 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -28,10 +28,6 @@ function(help_xcode_depends) endif() endfunction() -if("${CMAKE_GENERATOR}" MATCHES "Ninja") - set(HELP_NINJA 1) # TODO Why is this needed? -endif() - # The Intel compiler causes the MSVC linker to crash during # incremental linking, so avoid the /INCREMENTAL:YES flag. if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") @@ -218,7 +214,7 @@ try_compile(RESULT OUTPUT_VARIABLE OUTPUT) # Xcode is in serious need of help here -if(HELP_XCODE OR HELP_NINJA) +if(HELP_XCODE) try_compile(RESULT ${BuildDepends_BINARY_DIR}/Project ${BuildDepends_SOURCE_DIR}/Project -- cgit v0.12 From ef42e57d470db499a41c8bca695391c3e3e5cb86 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Nov 2014 15:29:51 -0500 Subject: Ninja: Use a TARGET_FILE variable to hold the link output file Use an explicit "$TARGET_FILE" variable instead of "$out" so that we can have multiple output files while still only referencing the main one in command lines. --- Source/cmNinjaNormalTargetGenerator.cxx | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 0cc3e3b..0614ae7 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -194,12 +194,7 @@ cmNinjaNormalTargetGenerator vars.ObjectDir = "$OBJECT_DIR"; - // TODO: - // Makefile generator expands to the plain target name - // with suffix. $out expands to a relative path. This difference - // could make trouble when switching to Ninja generator. Maybe - // using TARGET_NAME and RuleVariables::TargetName is a fix. - vars.Target = "$out"; + vars.Target = "$TARGET_FILE"; vars.SONameFlag = "$SONAME_FLAG"; vars.TargetSOName = "$SONAME"; @@ -252,7 +247,7 @@ cmNinjaNormalTargetGenerator << this->GetVisibleTypeName() << "."; cmOStringStream description; description << "Linking " << this->TargetLinkLanguage << " " - << this->GetVisibleTypeName() << " $out"; + << this->GetVisibleTypeName() << " $TARGET_FILE"; this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(), @@ -326,7 +321,7 @@ cmNinjaNormalTargetGenerator this->GetLocalGenerator()->ConvertToOutputFormat( mf->GetRequiredDefinition("CMAKE_COMMAND"), cmLocalGenerator::SHELL); - linkCmds.push_back(cmakeCommand + " -E remove $out"); + linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE"); } // TODO: Use ARCHIVE_APPEND for archives over a certain size. { @@ -450,6 +445,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetConfigName()); bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); + + vars["TARGET_FILE"] = + localGen.ConvertToOutputFormat(targetOutputReal, cmLocalGenerator::SHELL); + localGen.GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], @@ -509,6 +508,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); + if(target.HasImportLibrary()) + { + outputs.push_back(targetOutputImplib); + } } if (!this->SetMsvcTargetPdbVariable(vars)) @@ -659,16 +662,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } - if (!this->TargetNameImport.empty()) - { - // Since using multiple outputs would mess up the $out variable, use an - // alias for the import library. - globalGen.WritePhonyBuild(this->GetBuildFileStream(), - "Alias for import library.", - cmNinjaDeps(1, targetOutputImplib), - cmNinjaDeps(1, targetOutputReal)); - } - // Add aliases for the file name and the target name. globalGen.AddTargetAlias(this->TargetNameOut, &target); globalGen.AddTargetAlias(this->GetTargetName(), &target); -- cgit v0.12 From 67bd514adce689f4c7f537cdc446c01f7373f5a5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Nov 2014 18:32:44 -0500 Subject: Ninja: Refactor restat to be a string internally This will allow values other than "" and "1" to be generated in the rules.ninja file. --- Source/cmGlobalNinjaGenerator.cxx | 18 +++++++++--------- Source/cmGlobalNinjaGenerator.h | 4 ++-- Source/cmNinjaNormalTargetGenerator.cxx | 6 +++--- Source/cmNinjaTargetGenerator.cxx | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 60ab3e4..6f0586b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -242,7 +242,7 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ true, + /*restat*/ "1", /*generator*/ false); } @@ -309,7 +309,7 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule() /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } @@ -344,7 +344,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator) { // Make sure the rule has a name. @@ -408,10 +408,10 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "rspfile_content = " << rspcontent << "\n"; } - if(restat) + if(!restat.empty()) { cmGlobalNinjaGenerator::Indent(os, 1); - os << "restat = 1\n"; + os << "restat = " << restat << "\n"; } if(generator) @@ -607,7 +607,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator) { // Do not add the same rule twice. @@ -1122,7 +1122,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ true); cmLocalNinjaGenerator *ng = static_cast(lg); @@ -1206,7 +1206,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ false); WriteBuild(os, "Clean all the built files.", @@ -1229,7 +1229,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ false); WriteBuild(os, "Print all primary targets available.", diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a166938..3d443d8 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -125,7 +125,7 @@ public: const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator); /** @@ -245,7 +245,7 @@ public: const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator); bool HasRule(const std::string& name); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 0614ae7..48c4a2d 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -256,7 +256,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", rspfile, rspcontent, - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } @@ -278,7 +278,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", @@ -292,7 +292,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 80213d8..57fbcd3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -477,7 +477,7 @@ cmNinjaTargetGenerator deptype, /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } -- cgit v0.12