mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
FASTBuild: fix iface targets with private sources
When `PRIVATE` sources are added to an `INTERFACE` target A and A is a dependency of B - the target A ends up in "direct dependencies" of the B targets and it messes up the generated `fbuild.bff` file. Fixes: #27644
This commit is contained in:
committed by
Brad King
parent
50fd168a0e
commit
af8f4ca675
@@ -15,6 +15,7 @@
|
||||
#include "cmGlobalFastbuildGenerator.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
@@ -28,6 +29,9 @@ cmFastbuildUtilityTargetGenerator::cmFastbuildUtilityTargetGenerator(
|
||||
|
||||
void cmFastbuildUtilityTargetGenerator::Generate()
|
||||
{
|
||||
if (!this->GetGeneratorTarget()->IsInBuildSystem()) {
|
||||
return;
|
||||
}
|
||||
std::string targetName = GeneratorTarget->GetName();
|
||||
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
@@ -121,14 +125,27 @@ void cmFastbuildUtilityTargetGenerator::Generate()
|
||||
}
|
||||
this->GetGlobalGenerator()->AddTarget(std::move(exec));
|
||||
}
|
||||
// The target has to be in the build system, but has no custom commands
|
||||
// associated with it.
|
||||
if (fastbuildTarget.PreBuildDependencies.empty()) {
|
||||
if (fastbuildTarget.ExcludeFromAll) {
|
||||
return;
|
||||
std::vector<cmSourceFile*> sources;
|
||||
this->GetGeneratorTarget()->GetSourceFiles(sources, this->Config);
|
||||
if (sources.empty()) {
|
||||
FastbuildTargetDep dep{ FASTBUILD_NOOP_FILE_NAME };
|
||||
dep.Type = FastbuildTargetDepType::ORDER_ONLY;
|
||||
fastbuildTarget.PreBuildDependencies.emplace(std::move(dep));
|
||||
} else {
|
||||
for (cmSourceFile const* source : sources) {
|
||||
FastbuildTargetDep dep{
|
||||
this->GetGlobalGenerator()->ConvertToFastbuildPath(
|
||||
source->GetFullPath())
|
||||
};
|
||||
dep.Type = FastbuildTargetDepType::ARTIFACT;
|
||||
fastbuildTarget.PreBuildDependencies.emplace(std::move(dep));
|
||||
}
|
||||
}
|
||||
FastbuildTargetDep dep{ FASTBUILD_NOOP_FILE_NAME };
|
||||
dep.Type = FastbuildTargetDepType::ORDER_ONLY;
|
||||
fastbuildTarget.PreBuildDependencies.emplace(std::move(dep));
|
||||
}
|
||||
|
||||
fastbuildTarget.Hidden = false;
|
||||
this->AdditionalCleanFiles();
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ enum class FastbuildTargetDepType
|
||||
REGULAR,
|
||||
// Utility target dep.
|
||||
UTIL,
|
||||
// A physical file on disk.
|
||||
ARTIFACT,
|
||||
};
|
||||
struct FastbuildTargetDep
|
||||
{
|
||||
@@ -137,6 +139,7 @@ struct FastbuildTargetBase
|
||||
std::set<FastbuildTargetDep> PreBuildDependencies;
|
||||
bool Hidden = true;
|
||||
FastbuildTargetType Type;
|
||||
bool ExcludeFromAll = false;
|
||||
explicit FastbuildTargetBase(FastbuildTargetType TargetType)
|
||||
: Type(TargetType)
|
||||
{
|
||||
@@ -146,7 +149,6 @@ using FastbuildTargetPtrT = std::unique_ptr<FastbuildTargetBase>;
|
||||
|
||||
struct FastbuildAliasNode : public FastbuildTargetBase
|
||||
{
|
||||
bool ExcludeFromAll = false;
|
||||
FastbuildAliasNode()
|
||||
: FastbuildTargetBase(FastbuildTargetType::ALIAS)
|
||||
{
|
||||
@@ -169,7 +171,6 @@ struct FastbuildExecNode : public FastbuildTargetBase
|
||||
FastbuildAliasNode OutputsAlias;
|
||||
FastbuildAliasNode ByproductsAlias;
|
||||
std::string ConcurrencyGroupName;
|
||||
bool ExcludeFromAll = false;
|
||||
FastbuildExecNode()
|
||||
: FastbuildTargetBase(FastbuildTargetType::EXEC)
|
||||
{
|
||||
@@ -331,7 +332,6 @@ struct FastbuildTarget : public FastbuildTargetBase
|
||||
FastbuildExecNodes PreLinkExecNodes;
|
||||
FastbuildExecNodes PostBuildExecNodes;
|
||||
bool IsGlobal = false;
|
||||
bool ExcludeFromAll = false;
|
||||
bool AllowDistribution = true;
|
||||
FastbuildTarget()
|
||||
: FastbuildTargetBase(FastbuildTargetType::LINK)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# We just check that generation succeeds,
|
||||
# so any regex is fine.
|
||||
set(REGEX_TO_MATCH ".*")
|
||||
include(${RunCMake_SOURCE_DIR}/check.cmake)
|
||||
@@ -0,0 +1,6 @@
|
||||
add_library(iface_lib INTERFACE EXCLUDE_FROM_ALL)
|
||||
target_sources(iface_lib PRIVATE header.hpp)
|
||||
|
||||
add_library(static_lib STATIC main.cpp)
|
||||
|
||||
target_link_libraries(static_lib PRIVATE iface_lib)
|
||||
@@ -12,3 +12,4 @@ run_cmake(DisableCaching)
|
||||
run_cmake(DisableDistribution)
|
||||
run_cmake(SetCompilerProps)
|
||||
run_cmake(ImportedObjectLib)
|
||||
run_cmake(InterfaceWithPrivateSource)
|
||||
|
||||
Reference in New Issue
Block a user