diff options
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 3 | ||||
-rw-r--r-- | Source/cmExportTryCompileFileGenerator.cxx | 19 | ||||
-rw-r--r-- | Source/cmExportTryCompileFileGenerator.h | 5 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 14 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 7 | ||||
-rw-r--r-- | Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt | 4 |
9 files changed, 43 insertions, 25 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 34c6175..26e0db9 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -580,7 +580,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, if (!targets.empty()) { std::string fname = "/" + std::string(targetName) + "Targets.cmake"; - cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile); + cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile, + testLangs); tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); tcfg.SetConfig(tcConfig); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 798f2e6..87648cb 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -18,7 +18,8 @@ cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( cmGlobalGenerator* gg, const std::vector<std::string>& targets, - cmMakefile* mf) + cmMakefile* mf, std::set<std::string> const& langs) + : Languages(langs.begin(), langs.end()) { gg->CreateImportedGenerationObjects(mf, targets, this->Exports); } @@ -36,12 +37,14 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; + for (std::string const& lang : this->Languages) { #define FIND_TARGETS(PROPERTY) \ - this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps); + this->FindTargets("INTERFACE_" #PROPERTY, te, lang, emittedDeps); - CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) #undef FIND_TARGETS + } this->PopulateProperties(te, properties, emittedDeps); @@ -53,7 +56,7 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) std::string cmExportTryCompileFileGenerator::FindTargets( const std::string& propName, cmGeneratorTarget const* tgt, - std::set<cmGeneratorTarget const*>& emitted) + std::string const& language, std::set<cmGeneratorTarget const*>& emitted) { const char* prop = tgt->GetProperty(propName); if (!prop) { @@ -72,8 +75,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, - false, &gDummyHead, tgt, &dagChecker); + std::string result = + cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead, + tgt, &dagChecker, language); const std::set<cmGeneratorTarget const*>& allTargets = cge->GetAllTargetsSeen(); @@ -97,7 +101,8 @@ void cmExportTryCompileFileGenerator::PopulateProperties( if (p.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 || p.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 || p.find("INTERFACE_LINK_LIBRARIES") == 0) { - std::string evalResult = this->FindTargets(p, target, emitted); + std::string evalResult = + this->FindTargets(p, target, std::string(), emitted); std::vector<std::string> depends; cmSystemTools::ExpandListArgument(evalResult, depends); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 70c3857..ca2987c 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -21,7 +21,8 @@ class cmExportTryCompileFileGenerator : public cmExportFileGenerator public: cmExportTryCompileFileGenerator(cmGlobalGenerator* gg, std::vector<std::string> const& targets, - cmMakefile* mf); + cmMakefile* mf, + std::set<std::string> const& langs); /** Set the list of targets to export. */ void SetConfig(const std::string& config) { this->Config = config; } @@ -49,10 +50,12 @@ protected: private: std::string FindTargets(const std::string& prop, const cmGeneratorTarget* tgt, + std::string const& language, std::set<const cmGeneratorTarget*>& emitted); std::vector<cmGeneratorTarget const*> Exports; std::string Config; + std::vector<std::string> Languages; }; #endif diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b9e2978..66105b5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -387,14 +387,15 @@ static void handleSystemIncludesDep( cmLocalGenerator* lg, cmGeneratorTarget const* depTgt, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::vector<std::string>& result, bool excludeImported) + std::vector<std::string>& result, bool excludeImported, + std::string const& language) { if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker), + dagChecker, language), result); } if (!depTgt->IsImported() || excludeImported) { @@ -406,7 +407,7 @@ static void handleSystemIncludesDep( cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker), + dagChecker, language), result); } } @@ -738,7 +739,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } bool cmGeneratorTarget::IsSystemIncludeDirectory( - const std::string& dir, const std::string& config) const + const std::string& dir, const std::string& config, + const std::string& language) const { assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); std::string config_upper; @@ -761,7 +763,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, this, - &dagChecker), + &dagChecker, language), result); } @@ -769,7 +771,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( this->GetLinkImplementationClosure(config); for (cmGeneratorTarget const* dep : deps) { handleSystemIncludesDep(this->LocalGenerator, dep, config, this, - &dagChecker, result, excludeImported); + &dagChecker, result, excludeImported, language); } std::for_each(result.begin(), result.end(), diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1ee8a16..2f6ce33 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -413,7 +413,8 @@ public: const std::string& language) const; bool IsSystemIncludeDirectory(const std::string& dir, - const std::string& config) const; + const std::string& config, + const std::string& language) const; /** Add the target output files to the global generator manifest. */ void ComputeTargetManifest(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7fdf896..f8597af 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2031,7 +2031,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (emitted.insert(frameworkDir).second) { std::string incpath = this->XCodeEscapePath(frameworkDir); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) { + gtgt->IsSystemIncludeDirectory(frameworkDir, configName, + langForPreprocessor)) { sysfdirs.Add(incpath); } else { fdirs.Add(incpath); @@ -2040,7 +2041,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } else { std::string incpath = this->XCodeEscapePath(include); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(include, configName)) { + gtgt->IsSystemIncludeDirectory(include, configName, + langForPreprocessor)) { sysdirs.Add(incpath); } else { dirs.Add(incpath); @@ -2053,7 +2055,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (emitted.insert(fwDir).second) { std::string incpath = this->XCodeEscapePath(fwDir); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(fwDir, configName)) { + gtgt->IsSystemIncludeDirectory(fwDir, configName, + langForPreprocessor)) { sysfdirs.Add(incpath); } else { fdirs.Add(incpath); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 08f3c0f..cee540b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -718,7 +718,7 @@ std::string cmLocalGenerator::GetIncludeFlags( frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if (emitted.insert(frameworkDir).second) { if (sysFwSearchFlag && target && - target->IsSystemIncludeDirectory(i, config)) { + target->IsSystemIncludeDirectory(i, config, lang)) { includeFlags << sysFwSearchFlag; } else { includeFlags << fwSearchFlag; @@ -731,7 +731,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if (!flagUsed || repeatFlag) { if (sysIncludeFlag && target && - target->IsSystemIncludeDirectory(i, config)) { + target->IsSystemIncludeDirectory(i, config, lang)) { includeFlags << sysIncludeFlag; } else { includeFlags << includeFlag; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index fbfaa40..7c10110 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -725,8 +725,9 @@ static Json::Value DumpSourceFilesList( lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); for (const auto& include : includes) { - fileData.IncludePathList.push_back(std::make_pair( - include, target->IsSystemIncludeDirectory(include, config))); + fileData.IncludePathList.push_back( + std::make_pair(include, target->IsSystemIncludeDirectory( + include, config, fileData.Language))); } } @@ -1005,7 +1006,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, lg->GetIncludeDirectories(includePathList, target, lang, config, true); for (std::string const& i : includePathList) { ld.IncludePathList.push_back( - std::make_pair(i, target->IsSystemIncludeDirectory(i, config))); + std::make_pair(i, target->IsSystemIncludeDirectory(i, config, lang))); } } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index 5078f30..20bd601 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -32,7 +32,9 @@ target_link_libraries(consumer upstream config_specific) target_compile_options(consumer PRIVATE -Werror=unused-variable) add_library(iface IMPORTED INTERFACE) -set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only") +set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only>" + ) add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) |