summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2023-02-24 10:01:11 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-27 14:18:34 (GMT)
commita7f9c7da2618c795db534890124718fd0d9c73ce (patch)
tree2cd5286820740111a87520731c8cf86282118388 /Tests
parent9694504adcdc44492a2e088343cd5be1fd28d270 (diff)
downloadCMake-a7f9c7da2618c795db534890124718fd0d9c73ce.zip
CMake-a7f9c7da2618c795db534890124718fd0d9c73ce.tar.gz
CMake-a7f9c7da2618c795db534890124718fd0d9c73ce.tar.bz2
Add option to add SOVERSION to DLL names
Add variable/target property `[CMAKE_]DLL_NAME_WITH_SOVERSION`. Fixes: #24251 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt2
-rw-r--r--Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake18
-rw-r--r--Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/TargetArtifacts/dll.c6
5 files changed, 31 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 7ec9985..72de742 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -394,7 +394,7 @@ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STRE
endif()
add_RunCMake_test(ScriptMode)
add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
-add_RunCMake_test(TargetArtifacts)
+add_RunCMake_test(TargetArtifacts -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetProperties)
add_RunCMake_test(ToolchainFile)
diff --git a/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt
new file mode 100644
index 0000000..b375da6
--- /dev/null
+++ b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt
@@ -0,0 +1,2 @@
+.*exA_name="(libexA\.so\.2|libexA\.2\.dylib|(lib|cyg|msys-|)exA-2\.dll)"
+.*exB_name="(libexB\.so\.2|libexB\.2\.dylib|(lib|cyg|msys-|)exB-2\.dll)"
diff --git a/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake
new file mode 100644
index 0000000..82eca0b
--- /dev/null
+++ b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+add_library(exA SHARED dll.c)
+set_target_properties(exA PROPERTIES
+ SOVERSION 2
+ DLL_NAME_WITH_SOVERSION 1
+ )
+
+set(CMAKE_DLL_NAME_WITH_SOVERSION 1)
+add_library(exB SHARED dll.c)
+set_property(TARGET exB PROPERTY SOVERSION 2)
+
+add_custom_target(checkNames ALL
+ COMMAND ${CMAKE_COMMAND} -E echo exA_name="$<TARGET_FILE_NAME:exA>"
+ COMMAND ${CMAKE_COMMAND} -E echo exB_name="$<TARGET_FILE_NAME:exB>"
+ VERBATIM
+ )
+add_dependencies(checkNames exA exB)
diff --git a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake
index 2b5c4b8..de69936 100644
--- a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake
+++ b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake
@@ -9,7 +9,11 @@ function(run_cmake_and_verify_after_build case)
endif()
run_cmake(${case})
set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .)
endfunction()
+if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ run_cmake_and_verify_after_build(DLL-SOVERSION)
+endif()
run_cmake_and_verify_after_build(OutputDirs)
diff --git a/Tests/RunCMake/TargetArtifacts/dll.c b/Tests/RunCMake/TargetArtifacts/dll.c
new file mode 100644
index 0000000..31e1dbf
--- /dev/null
+++ b/Tests/RunCMake/TargetArtifacts/dll.c
@@ -0,0 +1,6 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ void dll(void)
+{
+}