diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-07-03 16:16:37 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2022-07-05 08:00:04 (GMT) |
commit | e8792da04b7980c11e0b1b62ea618953876d1f39 (patch) | |
tree | 44ce8851025edc83e29eeebba19406095f16fabe | |
parent | 2a336d855443d7db601bd79e80fce86726962cd2 (diff) | |
download | CMake-e8792da04b7980c11e0b1b62ea618953876d1f39.zip CMake-e8792da04b7980c11e0b1b62ea618953876d1f39.tar.gz CMake-e8792da04b7980c11e0b1b62ea618953876d1f39.tar.bz2 |
genex-LINK_LIBRARY: ensure correct generation inside LINK_GROUP genex
This fix ensures the following pattern is correctly handled:
$<LINK_GROUP:group_feat,$<LINK_LIBRARY:lib_feat,mylib>>
With:
CMAKE_LINK_GROUP_USING_group_feat = "—START_GROUP" "—END_GROUP"
CMAKE_LINK_LIBRARY_USING_lib_feat = "—PREFIX" "—LINK <LIBRARY>" "—SUFFIX"
Before the fix, we get the following generation:
—START_GROUP —PREFIX —LINK /path/to/mylib —END_GROUP —SUFFIX
—END_GROUP and —SUFFIX are in the wrong order
After the fix, we get the correct order:
—START_GROUP —PREFIX —LINK /path/to/mylib —SUFFIX —END_GROUP
5 files changed, 23 insertions, 0 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e156e3d..850b7a3 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -549,6 +549,17 @@ bool cmComputeLinkInformation::Compute() if (linkEntry.Kind == cmComputeLinkDepends::LinkEntry::Group) { const auto& groupFeature = this->GetGroupFeature(linkEntry.Feature); if (groupFeature.Supported) { + if (linkEntry.Item.Value == "</LINK_GROUP>" && + currentFeature != nullptr) { + // emit feature suffix, if any + if (!currentFeature->Suffix.empty()) { + this->Items.emplace_back( + BT<std::string>{ currentFeature->Suffix, + this->Items.back().Value.Backtrace }, + ItemIsPath::No); + } + currentFeature = nullptr; + } this->Items.emplace_back( BT<std::string>{ linkEntry.Item.Value == "<LINK_GROUP>" ? groupFeature.Prefix diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-check.cmake new file mode 100644 index 0000000..b6cabf5 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-PREFIX_LIBRARY\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIX_LIBRARY\"? +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --PREFIX_LIBRARY --LIBFLAG<base1> --LIBFLAG<base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake index 31eb7e2..fea2f91 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake @@ -20,6 +20,9 @@ set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--PREFIX_LIBRARY" "--LIBFLAG<LIBRARY>" "--SUFFIX_LIBRARY") +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) + set(CMAKE_C_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") set(CMAKE_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") set(CMAKE_LINK_GROUP_USING_feat2_SUPPORTED TRUE) @@ -53,6 +56,9 @@ target_link_libraries(LinkGroup_group-and-single PRIVATE "$<LINK_GROUP:feat1,bas add_library(LinkGroup_with-LINK_LIBRARY SHARED lib.c) target_link_libraries(LinkGroup_with-LINK_LIBRARY PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1>,base2>") +add_library(LinkGroup_with-LINK_LIBRARY2 SHARED lib.c) +target_link_libraries(LinkGroup_with-LINK_LIBRARY2 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,base1,base2>>") + add_library(LinkGroup_with-LINK_LIBRARY_OVERRIDE SHARED lib.c) target_link_libraries(LinkGroup_with-LINK_LIBRARY_OVERRIDE PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1,base3>,base2>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake index c1d74d0..3ebe269 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake @@ -46,6 +46,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" run_cmake_target(LINK_GROUP multiple-groups LinkGroup_multiple-groups) run_cmake_target(LINK_GROUP group-and-single LinkGroup_group-and-single) run_cmake_target(LINK_GROUP with-LINK_LIBRARY LinkGroup_with-LINK_LIBRARY) + run_cmake_target(LINK_GROUP with-LINK_LIBRARY2 LinkGroup_with-LINK_LIBRARY2) run_cmake_target(LINK_GROUP with-LINK_LIBRARY_OVERRIDE LinkGroup_with-LINK_LIBRARY_OVERRIDE) run_cmake(imported-target) |