diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-10-30 10:51:07 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-11-09 18:20:40 (GMT) |
commit | 7b99c42e57b11afe818827ac537ca020c020addd (patch) | |
tree | 8685083b5091ee50151974a827ecf2c06f4ed62f /Tests/RunCMake/CMP0156/RunCMakeTest.cmake | |
parent | 07501c16784f7e333da2f0d9045c029babfa38ea (diff) | |
download | CMake-7b99c42e57b11afe818827ac537ca020c020addd.zip CMake-7b99c42e57b11afe818827ac537ca020c020addd.tar.gz CMake-7b99c42e57b11afe818827ac537ca020c020addd.tar.bz2 |
Link step: Enable to configure deduplication of libraries
Some platforms, Apple or Windows for instance, do not require to duplicate
static libraries to resolve mutual dependencies. Moreover, Xcode version 15
emits a warning if a library is duplicated.
On Windows, enable a better control of libraries order.
Fixes: #20722, #25297
Diffstat (limited to 'Tests/RunCMake/CMP0156/RunCMakeTest.cmake')
-rw-r--r-- | Tests/RunCMake/CMP0156/RunCMakeTest.cmake | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0156/RunCMakeTest.cmake b/Tests/RunCMake/CMP0156/RunCMakeTest.cmake new file mode 100644 index 0000000..bd51830 --- /dev/null +++ b/Tests/RunCMake/CMP0156/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) + +# CMP0156 control how libraries are specified for the link step +# a sensible configuration is how circular dependency is handled + +macro(run_cmake_and_build test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + run_cmake(${test}) + set(RunCMake_TEST_NO_CLEAN TRUE) + run_cmake_command(${test}-build ${CMAKE_COMMAND} --build . --config Release) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_OUTPUT_MERGE) +endmacro() + +run_cmake(CMP0156-WARN) +run_cmake_and_build(CMP0156-OLD) +run_cmake_and_build(CMP0156-NEW) + +if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" + AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "15.0") + # special case for Apple: with CMP0156=OLD, linker will warning on duplicate libraries + run_cmake_and_build(CMP0156-OLD-AppleClang) + run_cmake_and_build(CMP0156-NEW-AppleClang) +endif() |