summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-28 15:38:29 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-28 16:06:24 (GMT)
commit9c14f1484871fb667611e531b9a7139279924f74 (patch)
treee7ae1fa23f0e35ef3806f4185fddee7af4b589b3 /Tests
parentf4b8176447699ba82c2bf7baf2d609d0d6e3259b (diff)
downloadCMake-9c14f1484871fb667611e531b9a7139279924f74.zip
CMake-9c14f1484871fb667611e531b9a7139279924f74.tar.gz
CMake-9c14f1484871fb667611e531b9a7139279924f74.tar.bz2
install(TARGETS): Do not apply installation tweaks to NAMELINK files
These files are symlinks to the real binaries, and we already apply tweaks to those. Previously we generated installation tweak code guarded by a `NOT IS_SYMLINK` condition that is never true. Drop the code altogether. Add a test covering the motivating use case, in which a `POST_BUILD` step modifies the namelink file to not actually be a symlink. Fixes: #24647
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake20
2 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index e5a0413..efafdd1 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -121,6 +121,10 @@ run_install_test(FILES-OPTIONAL)
run_install_test(DIRECTORY-OPTIONAL)
run_install_test(TARGETS-Defaults)
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ run_install_test(TARGETS-NAMELINK-No-Tweak)
+endif()
+
set(RunCMake_TEST_OPTIONS
"-DCMAKE_INSTALL_BINDIR:PATH=mybin"
"-DCMAKE_INSTALL_LIBDIR:PATH=mylib"
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake
new file mode 100644
index 0000000..879f4b8
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake
@@ -0,0 +1,20 @@
+enable_language(C)
+
+add_library(foo SHARED obj1.c)
+set_target_properties(foo PROPERTIES
+ VERSION 1.0
+ SOVERSION 1
+ INSTALL_RPATH "$ORIGIN"
+ )
+install(TARGETS foo DESTINATION lib)
+
+# Replace the .so "namelink" symlink with a linker script.
+# It is no longer a symlink, so any install tweaks would break.
+# This verifies that no install tweaks are added for the namelink.
+set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:foo>)")
+add_custom_command(TARGET foo POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:foo>"
+ COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:foo>"
+ COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:foo>"
+ VERBATIM
+ )