diff options
author | Eugene Shalygin <eugene.shalygin@gmail.com> | 2022-02-09 17:09:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-02-09 18:31:26 (GMT) |
commit | 83d79636bff4963f16215b219c5941618a58c7bd (patch) | |
tree | 5f021837afb1f65cefa4bd4433c61464f15b80e0 /Tests/RunCMake | |
parent | b91c4dfb758beecf796d6e455621c36602d2ec7d (diff) | |
download | CMake-83d79636bff4963f16215b219c5941618a58c7bd.zip CMake-83d79636bff4963f16215b219c5941618a58c7bd.tar.gz CMake-83d79636bff4963f16215b219c5941618a58c7bd.tar.bz2 |
install(TARGETS): Restore per-export INCLUDES DESTINATION
In commit 55e4753bbb (Refactor cmTargetExport removing
InterfaceIncludeDirecories, 2021-07-20, v3.22.0-rc1~337^2~1) the storage
of `INCLUDES DESTINATION` was moved into each target. However, a target
may be installed in multiple exports, and their `INCLUDES DESTINATION`
should not be mixed.
Convert the IncludeDirectoriesEntries vector to a map and modify access
function to store the directories lists with respect to cmExportTarget
object. This fixes error when the same target is exported more than once
via different exports and each for consequent export its include
directories list grows. Add a test for this case.
Fixes: #23183
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/install/RunCMakeTest.cmake | 1 |
5 files changed, 47 insertions, 0 deletions
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake new file mode 100644 index 0000000..97677ca --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake @@ -0,0 +1,19 @@ +set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg1/pkg1.cmake") +file(STRINGS "${pkg1_cmake}" pkg1_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) +set(pkg1_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"]]) +if(NOT pkg1_includes MATCHES "${pkg1_expect}") + set(RunCMake_TEST_FAILED "pkg1 has unexpected INTERFACE_INCLUDE_DIRECTORIES line: + ${pkg1_includes} +It does not match: + ${pkg1_expect}") +endif() + +set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg2/pkg2.cmake") +file(STRINGS "${pkg2_cmake}" pkg2_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) +set(pkg2_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"]]) +if(NOT pkg2_includes MATCHES "${pkg2_expect}") + set(RunCMake_TEST_FAILED "pkg2 has unexpected INTERFACE_INCLUDE_DIRECTORIES line: + ${pkg2_includes} +It does not match: + ${pkg2_expect}") +endif() diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt new file mode 100644 index 0000000..592f79c --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt @@ -0,0 +1,5 @@ +.+ +set_target_properties\(pkg1::foo PROPERTIES +.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc" +\) +.+ diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt new file mode 100644 index 0000000..ebfc43e --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt @@ -0,0 +1,5 @@ +.+ +set_target_properties\(pkg2::foo PROPERTIES +.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc" +\) +.+ diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake new file mode 100644 index 0000000..cac4ff2 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +add_library(foo STATIC empty.c) + +install(TARGETS foo + EXPORT pkg1 + ARCHIVE DESTINATION pkg1/lib + INCLUDES DESTINATION pkg1/inc + ) +install(EXPORT pkg1 DESTINATION pkg1) + +install(TARGETS foo + EXPORT pkg2 + ARCHIVE DESTINATION pkg2/lib + INCLUDES DESTINATION pkg2/inc + ) +install(EXPORT pkg2 DESTINATION pkg2) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index f79a3ea..7c12d4a 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -82,6 +82,7 @@ run_cmake(EXPORT-OldIFace) run_cmake(EXPORT-UnknownExport) run_cmake(EXPORT-NamelinkOnly) run_cmake(EXPORT-SeparateNamelink) +run_cmake(EXPORT-TargetTwice) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) |