mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 08:08:24 -05:00
add_custom_command: Properly recognize if sources depend on config
Fixes: #21349
This commit is contained in:
@@ -3098,12 +3098,17 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for target references in generator expressions.
|
// Check for target references in generator expressions.
|
||||||
for (std::string const& cl : cCmdLine) {
|
std::vector<std::string> const& configs =
|
||||||
const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
|
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
||||||
cge->SetQuiet(true);
|
for (std::string const& c : configs) {
|
||||||
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "");
|
for (std::string const& cl : cCmdLine) {
|
||||||
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
|
const std::unique_ptr<cmCompiledGeneratorExpression> cge =
|
||||||
targets.insert(geTargets.begin(), geTargets.end());
|
ge.Parse(cl);
|
||||||
|
cge->SetQuiet(true);
|
||||||
|
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), c);
|
||||||
|
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
|
||||||
|
targets.insert(geTargets.begin(), geTargets.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,3 +91,16 @@ target_compile_definitions(ObjLibFromGeneratedSources PRIVATE OBJ_SHARED)
|
|||||||
target_sources(ObjLibFromGeneratedSources PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp)
|
target_sources(ObjLibFromGeneratedSources PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp)
|
||||||
add_library(SharedLibFromObjLibFromGeneratedSources SHARED shared.cpp)
|
add_library(SharedLibFromObjLibFromGeneratedSources SHARED shared.cpp)
|
||||||
target_link_libraries(SharedLibFromObjLibFromGeneratedSources PRIVATE ObjLibFromGeneratedSources)
|
target_link_libraries(SharedLibFromObjLibFromGeneratedSources PRIVATE ObjLibFromGeneratedSources)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Make sure that additional build-events do not confuse CMake when using generated files.
|
||||||
|
add_library(SharedLibFromGeneratedSources SHARED)
|
||||||
|
set_property(TARGET SharedLibFromGeneratedSources PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||||
|
target_sources(SharedLibFromGeneratedSources PRIVATE
|
||||||
|
shared.cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp
|
||||||
|
)
|
||||||
|
add_custom_command(TARGET SharedLibFromGeneratedSources POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "$<TARGET_FILE:SharedLibFromGeneratedSources>"
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user