diff options
author | Brad King <brad.king@kitware.com> | 2020-10-26 14:28:09 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-26 14:28:30 (GMT) |
commit | f87360b78142e49a930ed23868726e279da28abd (patch) | |
tree | ce130673dcd3e5ca2f6f713c42bc39e6cbd4176c | |
parent | 227018866226afaac741fcd00ec3cc9579163b55 (diff) | |
parent | cd33bfcad57eca7c32d3f8e3260d9a6682c5d516 (diff) | |
download | CMake-f87360b78142e49a930ed23868726e279da28abd.zip CMake-f87360b78142e49a930ed23868726e279da28abd.tar.gz CMake-f87360b78142e49a930ed23868726e279da28abd.tar.bz2 |
Merge topic 'per-config-source-TARGET_FILE'
cd33bfcad5 add_custom_command: Properly recognize if sources depend on config
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5410
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 17 | ||||
-rw-r--r-- | Tests/ConfigSources/CMakeLists.txt | 13 |
2 files changed, 24 insertions, 6 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1ed82fd..fcfcc53 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3103,12 +3103,17 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) } // Check for target references in generator expressions. - for (std::string const& cl : cCmdLine) { - const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl); - cge->SetQuiet(true); - cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), ""); - std::set<cmGeneratorTarget*> geTargets = cge->GetTargets(); - targets.insert(geTargets.begin(), geTargets.end()); + std::vector<std::string> const& configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (std::string const& c : configs) { + for (std::string const& cl : cCmdLine) { + const std::unique_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(cl); + cge->SetQuiet(true); + cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), c); + std::set<cmGeneratorTarget*> geTargets = cge->GetTargets(); + targets.insert(geTargets.begin(), geTargets.end()); + } } } diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index 7b1a312..1db00cc 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -91,3 +91,16 @@ target_compile_definitions(ObjLibFromGeneratedSources PRIVATE OBJ_SHARED) target_sources(ObjLibFromGeneratedSources PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config_$<CONFIG>.cpp) add_library(SharedLibFromObjLibFromGeneratedSources SHARED shared.cpp) 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>" + ) |