FILE_SET: Evaluate usage requirements per consumer

$<TARGET_PROPERTY:prop> in the interface compile requirements of a file
set read the owner's property, and the result was shared by all
consumers. Evaluate with the consumer as head target and the owner as
current target, and cache per consumer.

Fixes: #28207
This commit is contained in:
Sergiu Deitsch committed 2026-10-30 22:45:22 +01:00
1 parent cafd167ba3
commit 3110f265a9
23 files changed
+232 -56

No files matched your search

+1
View File
@@ -100,6 +100,7 @@ Policies Introduced by CMake 4.6
.. toctree::
:maxdepth: 1
CMP0228: File set usage requirements are evaluated for the consumer. </policy/CMP0228>
CMP0227: AIX shared objects are named with VERSION and SOVERSION. </policy/CMP0227>
Policies Introduced by CMake 4.5
+31
View File
@@ -0,0 +1,31 @@
CMP0228
-------
.. versionadded:: 4.6
File set usage requirements are evaluated for the consumer.
The :prop_fs:`INTERFACE_COMPILE_DEFINITIONS`,
:prop_fs:`INTERFACE_COMPILE_OPTIONS`, and
:prop_fs:`INTERFACE_INCLUDE_DIRECTORIES` file set properties specify usage
requirements for compiling the sources of a file set in a consuming target.
In CMake 4.5 and below, generator expressions in these properties are
evaluated for the target that owns the file set, so that
:genex:`TARGET_PROPERTY:prop` reads ``prop`` from the owner rather than from
the consumer.
CMake 4.6 and above prefer to evaluate these properties for the consumer, as
for other :ref:`usage requirements <Target Usage Requirements>`. This policy
provides compatibility with projects that have not been updated to expect the
new behavior. Its setting is recorded by each target as it is created, and
affects the file sets owned by that target.
The ``OLD`` behavior for this policy is to evaluate the properties for the
target that owns the file set. The ``NEW`` behavior is to evaluate them for
the consumer.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.6
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
.. include:: include/STANDARD_ADVICE.rst
.. include:: include/DEPRECATED.rst
@@ -0,0 +1,7 @@
fileset-interface-consumer
--------------------------
* Generator expressions in the :prop_fs:`INTERFACE_COMPILE_DEFINITIONS`,
:prop_fs:`INTERFACE_COMPILE_OPTIONS`, and
:prop_fs:`INTERFACE_INCLUDE_DIRECTORIES` file set properties are now
evaluated for the consumer. See policy :policy:`CMP0228`.
+6 -3
View File
@@ -158,7 +158,8 @@ std::string cmFastbuildNormalTargetGenerator::DetectCompilerFlags(
if (fileSet) {
auto fsIncludes = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetIncludeDirectories(this->Config, language)
: fileSet->GetInterfaceIncludeDirectories(this->Config, language);
: fileSet->GetInterfaceIncludeDirectories(this->Config, language,
this->GeneratorTarget);
if (!fsIncludes.empty()) {
this->LocalGenerator->AppendIncludeDirectories(
sourceIncludesVec, cm::remove_BT(fsIncludes), srcFile);
@@ -191,7 +192,8 @@ std::string cmFastbuildNormalTargetGenerator::DetectCompilerFlags(
if (fileSet) {
auto options = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileOptions(this->Config, language)
: fileSet->GetInterfaceCompileOptions(this->Config, language);
: fileSet->GetInterfaceCompileOptions(this->Config, language,
this->GeneratorTarget);
if (!options.empty()) {
this->LocalGenerator->AppendCompileOptions(compileFlags,
cm::remove_BT(options));
@@ -478,7 +480,8 @@ std::string cmFastbuildNormalTargetGenerator::ComputeDefines(
this->Config, &srcFile)) {
auto fsDefines = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileDefinitions(this->Config, language)
: fileSet->GetInterfaceCompileDefinitions(this->Config, language);
: fileSet->GetInterfaceCompileDefinitions(this->Config, language,
this->GeneratorTarget);
if (!fsDefines.empty()) {
this->LocalGenerator->AppendDefines(defines, fsDefines);
}
+6 -5
View File
@@ -1530,7 +1530,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
if (fileSet) {
for (BT<std::string> const& tmpOpt : fileSet->BelongsTo(this->GT)
? fileSet->GetCompileOptions(this->Config, fd.Language)
: fileSet->GetInterfaceCompileOptions(this->Config, fd.Language)) {
: fileSet->GetInterfaceCompileOptions(this->Config, fd.Language,
this->GT)) {
// We need to use the AppendCompileOptions method so we handle situations
// where backtrace entries have list and properly escape flags.
std::string tmp;
@@ -1583,8 +1584,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
if (fileSet) {
for (BT<std::string> const& tmpInclude : fileSet->BelongsTo(this->GT)
? fileSet->GetIncludeDirectories(this->Config, fd.Language)
: fileSet->GetInterfaceIncludeDirectories(this->Config,
fd.Language)) {
: fileSet->GetInterfaceIncludeDirectories(this->Config, fd.Language,
this->GT)) {
// We need to use the AppendIncludeDirectories method so we handle
// situations where backtrace entries have lists.
std::vector<std::string> tmp;
@@ -1653,8 +1654,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
if (fileSet) {
for (BT<std::string> const& tmpDef : fileSet->BelongsTo(this->GT)
? fileSet->GetCompileDefinitions(this->Config, fd.Language)
: fileSet->GetInterfaceCompileDefinitions(this->Config,
fd.Language)) {
: fileSet->GetInterfaceCompileDefinitions(this->Config, fd.Language,
this->GT)) {
// We need to use the AppendDefines method so we handle situations where
// backtrace entries have lists.
std::set<std::string> tmp;
+27 -12
View File
@@ -26,6 +26,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -169,6 +170,14 @@ std::vector<BT<std::string>> ProcessIncludes(
}
return includes;
}
// The target that interface usage requirements of a file set owned by
// `owner` are evaluated for when compiling the sources of `consumer`.
cmGeneratorTarget const* GetUsageRequirementTarget(
cmGeneratorTarget const* owner, cmGeneratorTarget const* consumer)
{
return owner->GetPolicyStatusCMP0228() == cmPolicies::NEW ? consumer : owner;
}
}
//
@@ -260,9 +269,10 @@ std::vector<BT<std::string>> cmGeneratorFileSet::GetIncludeDirectories(
}
std::vector<BT<std::string>>
cmGeneratorFileSet::GetInterfaceIncludeDirectories(
std::string const& config, std::string const& lang) const
std::string const& config, std::string const& lang,
cmGeneratorTarget const* consumer) const
{
ConfigAndLanguage cacheKey(config, lang);
ConsumerConfigAndLanguage cacheKey(consumer, config, lang);
{
auto it = this->InterfaceIncludeDirectoriesCache.find(cacheKey);
if (it != this->InterfaceIncludeDirectoriesCache.end()) {
@@ -276,8 +286,9 @@ cmGeneratorFileSet::GetInterfaceIncludeDirectories(
};
cm::EvaluatedTargetPropertyEntries entries =
cm::EvaluateTargetPropertyEntries(this->Target, context, &dagChecker,
this->InterfaceIncludeDirectories);
cm::EvaluateTargetPropertyEntries(
GetUsageRequirementTarget(this->Target, consumer), context, &dagChecker,
this->InterfaceIncludeDirectories, this);
auto includes = ProcessIncludes(this->Target, this->GetName(),
"INTERFACE_INCLUDE_DIRECTORIES"_s, entries);
this->InterfaceIncludeDirectoriesCache.emplace(cacheKey, includes);
@@ -311,9 +322,10 @@ std::vector<BT<std::string>> cmGeneratorFileSet::GetCompileOptions(
return options;
}
std::vector<BT<std::string>> cmGeneratorFileSet::GetInterfaceCompileOptions(
std::string const& config, std::string const& language) const
std::string const& config, std::string const& language,
cmGeneratorTarget const* consumer) const
{
ConfigAndLanguage cacheKey(config, language);
ConsumerConfigAndLanguage cacheKey(consumer, config, language);
{
auto it = this->InterfaceCompileOptionsCache.find(cacheKey);
if (it != this->InterfaceCompileOptionsCache.end()) {
@@ -328,8 +340,9 @@ std::vector<BT<std::string>> cmGeneratorFileSet::GetInterfaceCompileOptions(
};
cm::EvaluatedTargetPropertyEntries entries =
cm::EvaluateTargetPropertyEntries(this->Target, context, &dagChecker,
this->InterfaceCompileOptions);
cm::EvaluateTargetPropertyEntries(
GetUsageRequirementTarget(this->Target, consumer), context, &dagChecker,
this->InterfaceCompileOptions, this);
auto options = ProcessOptions(entries, OptionsParse::Shell);
this->InterfaceCompileOptionsCache.emplace(cacheKey, options);
@@ -363,9 +376,10 @@ std::vector<BT<std::string>> cmGeneratorFileSet::GetCompileDefinitions(
}
std::vector<BT<std::string>>
cmGeneratorFileSet::GetInterfaceCompileDefinitions(
std::string const& config, std::string const& language) const
std::string const& config, std::string const& language,
cmGeneratorTarget const* consumer) const
{
ConfigAndLanguage cacheKey(config, language);
ConsumerConfigAndLanguage cacheKey(consumer, config, language);
{
auto it = this->InterfaceCompileDefinitionsCache.find(cacheKey);
if (it != this->InterfaceCompileDefinitionsCache.end()) {
@@ -380,8 +394,9 @@ cmGeneratorFileSet::GetInterfaceCompileDefinitions(
};
cm::EvaluatedTargetPropertyEntries entries =
cm::EvaluateTargetPropertyEntries(this->Target, context, &dagChecker,
this->InterfaceCompileDefinitions);
cm::EvaluateTargetPropertyEntries(
GetUsageRequirementTarget(this->Target, consumer), context, &dagChecker,
this->InterfaceCompileDefinitions, this);
auto defines = ProcessOptions(entries);
this->InterfaceCompileDefinitionsCache.emplace(cacheKey, defines);
+16 -6
View File
@@ -8,6 +8,7 @@
#include <map>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
@@ -64,17 +65,20 @@ public:
std::vector<BT<std::string>> GetIncludeDirectories(
std::string const& config, std::string const& lang) const;
std::vector<BT<std::string>> GetInterfaceIncludeDirectories(
std::string const& config, std::string const& lang) const;
std::string const& config, std::string const& lang,
cmGeneratorTarget const* consumer) const;
std::vector<BT<std::string>> GetCompileOptions(
std::string const& config, std::string const& language) const;
std::vector<BT<std::string>> GetInterfaceCompileOptions(
std::string const& config, std::string const& language) const;
std::string const& config, std::string const& language,
cmGeneratorTarget const* consumer) const;
std::vector<BT<std::string>> GetCompileDefinitions(
std::string const& config, std::string const& language) const;
std::vector<BT<std::string>> GetInterfaceCompileDefinitions(
std::string const& config, std::string const& language) const;
std::string const& config, std::string const& language,
cmGeneratorTarget const* consumer) const;
std::vector<BT<std::string>> const& GetDirectoryEntries() const;
std::vector<BT<std::string>> const& GetFileEntries() const;
@@ -151,10 +155,16 @@ private:
using ConfigAndLanguage = std::pair<std::string, std::string>;
using ConfigAndLanguageToBTStrings =
std::map<ConfigAndLanguage, std::vector<BT<std::string>>>;
using ConsumerConfigAndLanguage =
std::tuple<cmGeneratorTarget const*, std::string, std::string>;
using ConsumerConfigAndLanguageToBTStrings =
std::map<ConsumerConfigAndLanguage, std::vector<BT<std::string>>>;
mutable ConfigAndLanguageToBTStrings IncludeDirectoriesCache;
mutable ConfigAndLanguageToBTStrings InterfaceIncludeDirectoriesCache;
mutable ConsumerConfigAndLanguageToBTStrings
InterfaceIncludeDirectoriesCache;
mutable ConfigAndLanguageToBTStrings CompileOptionsCache;
mutable ConfigAndLanguageToBTStrings InterfaceCompileOptionsCache;
mutable ConsumerConfigAndLanguageToBTStrings InterfaceCompileOptionsCache;
mutable ConfigAndLanguageToBTStrings CompileDefinitionsCache;
mutable ConfigAndLanguageToBTStrings InterfaceCompileDefinitionsCache;
mutable ConsumerConfigAndLanguageToBTStrings
InterfaceCompileDefinitionsCache;
};
+3 -3
View File
@@ -2292,7 +2292,7 @@ cmGeneratorTarget::GetClassifiedFlagsForSource(cmSourceFile const* sf,
{
auto fsIncludes = fileSet->BelongsTo(this)
? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(config, lang);
: fileSet->GetInterfaceIncludeDirectories(config, lang, this);
if (!fsIncludes.empty()) {
std::vector<std::string> includes;
lg->AppendIncludeDirectories(includes, cm::remove_BT(fsIncludes), *sf);
@@ -2423,7 +2423,7 @@ cmGeneratorTarget::GetClassifiedFlagsForSource(cmSourceFile const* sf,
{
auto fsDefines = fileSet->BelongsTo(this)
? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(config, lang);
: fileSet->GetInterfaceCompileDefinitions(config, lang, this);
if (!fsDefines.empty()) {
std::set<std::string> defines;
lg->AppendDefines(defines, fsDefines);
@@ -2442,7 +2442,7 @@ cmGeneratorTarget::GetClassifiedFlagsForSource(cmSourceFile const* sf,
{
auto options = fileSet->BelongsTo(this)
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(config, lang);
: fileSet->GetInterfaceCompileOptions(config, lang, this);
if (!options.empty()) {
std::string compileFlags;
lg->AppendCompileOptions(compileFlags, cm::remove_BT(options));
+6 -3
View File
@@ -519,15 +519,18 @@ void cmGhsMultiTargetGenerator::WriteFileSetProperty(
if (propName == "COMPILE_OPTIONS"_s) {
entries = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileOptions(this->ConfigName, lang)
: fileSet->GetInterfaceCompileOptions(this->ConfigName, lang);
: fileSet->GetInterfaceCompileOptions(this->ConfigName, lang,
this->GeneratorTarget);
} else if (propName == "COMPILE_DEFINITIONS"_s) {
entries = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileDefinitions(this->ConfigName, lang)
: fileSet->GetInterfaceCompileDefinitions(this->ConfigName, lang);
: fileSet->GetInterfaceCompileDefinitions(this->ConfigName, lang,
this->GeneratorTarget);
} else if (propName == "INCLUDE_DIRECTORIES"_s) {
entries = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetIncludeDirectories(this->ConfigName, lang)
: fileSet->GetInterfaceIncludeDirectories(this->ConfigName, lang);
: fileSet->GetInterfaceIncludeDirectories(this->ConfigName, lang,
this->GeneratorTarget);
}
for (auto const& entry : entries) {
+3 -3
View File
@@ -1324,7 +1324,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
if (fileSet) {
auto options = fileSet->BelongsTo(gtgt)
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(config, lang);
: fileSet->GetInterfaceCompileOptions(config, lang, gtgt);
if (!options.empty()) {
lg->AppendCompileOptions(flags, cm::remove_BT(options));
}
@@ -1351,7 +1351,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
if (fileSet) {
auto fsDefines = fileSet->BelongsTo(gtgt)
? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(config, lang);
: fileSet->GetInterfaceCompileDefinitions(config, lang, gtgt);
if (!fsDefines.empty()) {
this->AppendDefines(flagsBuild, cm::remove_BT(fsDefines), true);
}
@@ -1374,7 +1374,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
if (fileSet) {
auto fsIncludes = fileSet->BelongsTo(gtgt)
? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(config, lang);
: fileSet->GetInterfaceIncludeDirectories(config, lang, gtgt);
if (!fsIncludes.empty()) {
lg->AppendIncludeDirectories(includes, cm::remove_BT(fsIncludes), *sf);
}
+3 -3
View File
@@ -1528,7 +1528,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
if (fileSet) {
auto options = fileSet->BelongsTo(gt)
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(config, lang);
: fileSet->GetInterfaceCompileOptions(config, lang, gt);
if (!options.empty()) {
lg->AppendCompileOptions(fc.CompileFlags, cm::remove_BT(options));
}
@@ -1595,7 +1595,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
if (fileSet) {
auto defines = fileSet->BelongsTo(gt)
? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(config, lang);
: fileSet->GetInterfaceCompileDefinitions(config, lang, gt);
if (!defines.empty()) {
if (!fc.CompileDefs.empty()) {
fc.CompileDefs += ';';
@@ -1609,7 +1609,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
if (fileSet) {
auto includes = fileSet->BelongsTo(gt)
? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(config, lang);
: fileSet->GetInterfaceIncludeDirectories(config, lang, gt);
if (!includes.empty()) {
fc.IncludeDirs = cmList::to_string(includes);
needfc = true;
+6 -3
View File
@@ -784,7 +784,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
if (fileSet) {
auto options = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(config, lang);
: fileSet->GetInterfaceCompileOptions(config, lang,
this->GeneratorTarget);
if (!options.empty()) {
this->LocalGenerator->AppendCompileOptions(flags,
cm::remove_BT(options));
@@ -825,7 +826,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
if (fileSet) {
auto fsIncludes = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(config, lang);
: fileSet->GetInterfaceIncludeDirectories(config, lang,
this->GeneratorTarget);
if (!fsIncludes.empty()) {
this->LocalGenerator->AppendIncludeDirectories(
includes, cm::remove_BT(fsIncludes), source);
@@ -878,7 +880,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
if (fileSet) {
auto fsDefines = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(config, lang);
: fileSet->GetInterfaceCompileDefinitions(config, lang,
this->GeneratorTarget);
if (!fsDefines.empty()) {
this->LocalGenerator->AppendDefines(defines, fsDefines);
*this->FlagFileStream << "# Custom defines (File Set '"
+6 -3
View File
@@ -247,7 +247,8 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
if (fileSet) {
auto options = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileOptions(config, language)
: fileSet->GetInterfaceCompileOptions(config, language);
: fileSet->GetInterfaceCompileOptions(config, language,
this->GeneratorTarget);
if (!options.empty()) {
this->LocalGenerator->AppendCompileOptions(flags,
cm::remove_BT(options));
@@ -354,7 +355,8 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
config, source)) {
auto fsDefines = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetCompileDefinitions(config, language)
: fileSet->GetInterfaceCompileDefinitions(config, language);
: fileSet->GetInterfaceCompileDefinitions(config, language,
this->GeneratorTarget);
if (!fsDefines.empty()) {
this->LocalGenerator->AppendDefines(defines, fsDefines);
}
@@ -377,7 +379,8 @@ std::string cmNinjaTargetGenerator::ComputeIncludes(
config, source)) {
auto fsIncludes = fileSet->BelongsTo(this->GeneratorTarget)
? fileSet->GetIncludeDirectories(config, language)
: fileSet->GetInterfaceIncludeDirectories(config, language);
: fileSet->GetInterfaceIncludeDirectories(config, language,
this->GeneratorTarget);
if (!fsIncludes.empty()) {
this->LocalGenerator->AppendIncludeDirectories(
includes, cm::remove_BT(fsIncludes), *source);
+6 -2
View File
@@ -685,7 +685,10 @@ class cmMakefile;
4, 5, 0, WARN) \
SELECT(POLICY, CMP0227, \
"AIX shared objects are named with VERSION and SOVERSION.", 4, 6, 0, \
WARN)
WARN) \
SELECT(POLICY, CMP0228, \
"File set usage requirements are evaluated for the consumer.", 4, 6, \
0, WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -746,7 +749,8 @@ class cmMakefile;
F(CMP0215) \
F(CMP0216) \
F(CMP0226) \
F(CMP0227)
F(CMP0227) \
F(CMP0228)
#define CM_FOR_EACH_CUSTOM_COMMAND_POLICY(F) \
F(CMP0116) \
+10 -10
View File
@@ -3036,18 +3036,18 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
if (fileSet) {
fileSetBelongsToTarget = fileSet->BelongsTo(this->GeneratorTarget);
fsOptions =
cm::remove_BT(fileSetBelongsToTarget
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(config, lang));
fsOptions = cm::remove_BT(fileSetBelongsToTarget
? fileSet->GetCompileOptions(config, lang)
: fileSet->GetInterfaceCompileOptions(
config, lang, this->GeneratorTarget));
fsDefines = cm::remove_BT(
fileSetBelongsToTarget
? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(config, lang));
fileSetBelongsToTarget ? fileSet->GetCompileDefinitions(config, lang)
: fileSet->GetInterfaceCompileDefinitions(
config, lang, this->GeneratorTarget));
fsIncludes = cm::remove_BT(
fileSetBelongsToTarget
? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(config, lang));
fileSetBelongsToTarget ? fileSet->GetIncludeDirectories(config, lang)
: fileSet->GetInterfaceIncludeDirectories(
config, lang, this->GeneratorTarget));
}
bool const shouldScanForModules = lang == "CXX"_s &&
@@ -0,0 +1,2 @@
set(CMP0228_OWNER NEW)
include(CMP0228-common.cmake)
@@ -0,0 +1,2 @@
set(CMP0228_OWNER OLD)
include(CMP0228-common.cmake)
@@ -0,0 +1 @@
include(CMP0228-common.cmake)
@@ -0,0 +1,28 @@
enable_language(C)
# The policy setting of the file set owner applies.
if (DEFINED CMP0228_OWNER)
cmake_policy(SET CMP0228 ${CMP0228_OWNER})
endif()
add_subdirectory(FileSetInterfaceConsumer)
# The policy setting of the consumers must not matter.
if (CMP0228_OWNER STREQUAL "NEW")
cmake_policy(SET CMP0228 OLD)
else()
cmake_policy(SET CMP0228 NEW)
endif()
foreach (id IN ITEMS 1 2)
add_executable(consumer${id})
set_property(TARGET consumer${id} PROPERTY FS_ID ${id})
if (CMP0228_OWNER STREQUAL "NEW")
# Each consumer compiles the file set with the requirements evaluated for
# it.
target_compile_definitions(consumer${id} PRIVATE EXPECTED_ID=${id})
else()
# The requirements are evaluated for the owner of the file set.
target_compile_definitions(consumer${id} PRIVATE EXPECTED_ID=0)
endif()
target_link_libraries(consumer${id} PRIVATE iface)
endforeach()
@@ -0,0 +1,27 @@
foreach (id IN ITEMS 0 1 2)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/inc${id}/consumer_id.h"
"#define INC_ID ${id}\n")
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/owner_local_inc/owner_local.h"
"#define OWNER_LOCAL_INC\n")
# Visible only in this directory, so it must be looked up here rather than in
# the directory of the consumers.
add_library(owner_local INTERFACE IMPORTED)
set_property(TARGET owner_local PROPERTY LOCAL_DEF OWNER_LOCAL_DEF)
set_property(TARGET owner_local PROPERTY LOCAL_OPT -DOWNER_LOCAL_OPT)
set_property(TARGET owner_local PROPERTY LOCAL_INC owner_local_inc)
add_library(iface INTERFACE)
target_sources(iface INTERFACE FILE_SET a TYPE SOURCES FILES consumer.c)
set_property(TARGET iface PROPERTY FS_ID 0)
set_property(FILE_SET a TARGET iface PROPERTY INTERFACE_COMPILE_DEFINITIONS
DEF_ID=$<TARGET_PROPERTY:FS_ID>
$<TARGET_PROPERTY:owner_local,LOCAL_DEF>)
set_property(FILE_SET a TARGET iface PROPERTY INTERFACE_COMPILE_OPTIONS
-DOPT_ID=$<TARGET_PROPERTY:FS_ID>
$<TARGET_PROPERTY:owner_local,LOCAL_OPT>)
set_property(FILE_SET a TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_BINARY_DIR}/inc$<TARGET_PROPERTY:FS_ID>"
"${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:owner_local,LOCAL_INC>")
@@ -0,0 +1,31 @@
#include "consumer_id.h"
#include "owner_local.h"
#if DEF_ID != EXPECTED_ID
# error DEF_ID does not match EXPECTED_ID of the consumer
#endif
#if OPT_ID != EXPECTED_ID
# error OPT_ID does not match EXPECTED_ID of the consumer
#endif
#if INC_ID != EXPECTED_ID
# error INC_ID does not match EXPECTED_ID of the consumer
#endif
#ifndef OWNER_LOCAL_DEF
# error OWNER_LOCAL_DEF not defined
#endif
#ifndef OWNER_LOCAL_OPT
# error OWNER_LOCAL_OPT not defined
#endif
#ifndef OWNER_LOCAL_INC
# error OWNER_LOCAL_INC not defined
#endif
int main(void)
{
return 0;
}
@@ -33,6 +33,9 @@ run_and_build(FileSetProperties)
run_and_build(CustomCommandInput)
run_and_build(IncludeDirectoriesOrder)
run_and_build(FileSetTransitivity)
run_and_build(CMP0228-NEW)
run_and_build(CMP0228-OLD)
run_and_build(CMP0228-WARN)
run_and_check(CompileOptionsOrder)
if(APPLE)
run_cmake(FileSetFramework1)
@@ -60,6 +60,7 @@
\* CMP0216
\* CMP0226
\* CMP0227
\* CMP0228
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)