summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-21 18:35:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-21 18:35:59 (GMT)
commita4b04e62fc44f36982308e9d3be6611b5f9cd4ce (patch)
tree09bb237460933d208e3021493f7583601ac6a206 /Tests
parentccc11d0776109c9d37f12b8332f9bc27f3bb41bf (diff)
parentdabe56de58a32768f0dff740f83539ab8337b132 (diff)
downloadCMake-a4b04e62fc44f36982308e9d3be6611b5f9cd4ce.zip
CMake-a4b04e62fc44f36982308e9d3be6611b5f9cd4ce.tar.gz
CMake-a4b04e62fc44f36982308e9d3be6611b5f9cd4ce.tar.bz2
Merge topic 'LINK_LIBRARY-WHOLE_ARCHIVE'
dabe56de58 genex-LINK_LIBRARY: Add feature WHOLE_ARCHIVE Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: huangqinjin <huangqinjin@gmail.com> Merge-request: !7064
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake14
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake11
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake34
-rw-r--r--Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake34
4 files changed, 57 insertions, 36 deletions
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
index 349310f..021de41 100644
--- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
@@ -67,8 +67,8 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
OR (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER "1900")
OR (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
- run_cmake(whole_archive)
- run_cmake_target(whole_archive link-exe main)
+ run_cmake(load_archive)
+ run_cmake_target(load_archive link-exe main)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
run_cmake(weak_library)
@@ -110,3 +110,13 @@ endif()
if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12")
run_cmake_target(apple_library needed_library main-needed_library)
endif()
+
+# WHOLE_ARCHIVE feature
+if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
+ ((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC")))
+ OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND
+ (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9"))
+ OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN")
+ run_cmake(feature-WHOLE_ARCHIVE)
+ run_cmake_target(feature-WHOLE_ARCHIVE link-exe main)
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake
new file mode 100644
index 0000000..e525325
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake
@@ -0,0 +1,11 @@
+
+enable_language(C)
+
+add_library(base STATIC base.c unref.c)
+target_compile_definitions(base PUBLIC STATIC_BASE)
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,base>")
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake
new file mode 100644
index 0000000..a0bbb43
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake
@@ -0,0 +1,34 @@
+
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED TRUE)
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "-force_load <LIB_ITEM>")
+elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE linker_help
+ ERROR_VARIABLE linker_help)
+ if(linker_help MATCHES "--push-state" AND linker_help MATCHES "--pop-state")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+ else()
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "/WHOLEARCHIVE:<LIBRARY>")
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED FALSE)
+endif()
+
+add_library(base STATIC base.c unref.c)
+target_compile_definitions(base PUBLIC STATIC_BASE)
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:load_archive,base>")
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake
deleted file mode 100644
index 93082a4..0000000
--- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/whole_archive.cmake
+++ /dev/null
@@ -1,34 +0,0 @@
-
-enable_language(C)
-
-set(CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED TRUE)
-if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
- set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "-force_load <LIB_ITEM>")
-elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
- execute_process(COMMAND "${CMAKE_LINKER}" --help
- OUTPUT_VARIABLE linker_help
- ERROR_VARIABLE linker_help)
- if(linker_help MATCHES "--push-state" AND linker_help MATCHES "--pop-state")
- set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "LINKER:--push-state,--whole-archive"
- "<LINK_ITEM>"
- "LINKER:--pop-state")
- else()
- set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "LINKER:--whole-archive"
- "<LINK_ITEM>"
- "LINKER:--no-whole-archive")
- endif()
-elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
- set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "/WHOLEARCHIVE:<LIBRARY>")
-else()
- # feature not yet supported for the other environments
- set(CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED FALSE)
-endif()
-
-add_library(base STATIC base.c unref.c)
-target_compile_definitions(base PUBLIC STATIC_BASE)
-
-add_library(lib SHARED lib.c)
-target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:whole_archive,base>")
-
-add_executable(main main.c)
-target_link_libraries(main PRIVATE lib)