mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 20:50:43 -06:00
Merge topic 'genex-COMPILE_LANGUAGE-system-include'
1b5e52fd65Genex: Fix COMPILE_LANGUAGE propagation through try_compile2deb9b7f34Genex: Fix COMPILE_LANGUAGE in SYSTEM include directories Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1844
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user