diff options
author | Brad King <brad.king@kitware.com> | 2020-01-28 15:58:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-28 15:59:03 (GMT) |
commit | b6da71e299ccdd202f1ea35f33cfcfeb36467e1d (patch) | |
tree | ee13e7ad9d9c5205621f1cb72896665a146aa36b /Tests | |
parent | e4e41d33d62236f60d909bd1d06b417590933980 (diff) | |
parent | 6a84f0b79189be4c982a6ba55c5cdcafee118813 (diff) | |
download | CMake-b6da71e299ccdd202f1ea35f33cfcfeb36467e1d.zip CMake-b6da71e299ccdd202f1ea35f33cfcfeb36467e1d.tar.gz CMake-b6da71e299ccdd202f1ea35f33cfcfeb36467e1d.tar.bz2 |
Merge topic 'osx-version-flags'
6a84f0b791 macOS: Test OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties
4a62e3d97c macOS: Add OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4274
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/MacOSVersions/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake | 27 | ||||
-rw-r--r-- | Tests/RunCMake/MacOSVersions/MacOSVersions.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/MacOSVersions/foo.c | 4 |
6 files changed, 55 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index dae3d17..ad70a34 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -306,6 +306,7 @@ add_RunCMake_test(test_include_dirs) add_RunCMake_test(BundleUtilities) if(APPLE) add_RunCMake_test(INSTALL_NAME_DIR) + add_RunCMake_test(MacOSVersions) endif() function(add_RunCMake_test_try_compile) diff --git a/Tests/RunCMake/MacOSVersions/CMakeLists.txt b/Tests/RunCMake/MacOSVersions/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake b/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake new file mode 100644 index 0000000..c4faa8b --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake @@ -0,0 +1,27 @@ +set(cfg_dir) +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(cfg_dir /Debug) +endif() + +set(lib "${RunCMake_TEST_BINARY_DIR}${cfg_dir}/libfoo.1.0.dylib") +if(NOT EXISTS "${lib}") + set(RunCMake_TEST_FAILED "Library file is missing:\n ${lib}") + return() +endif() + +execute_process(COMMAND otool -l "${lib}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) +if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + set(RunCMake_TEST_FAILED "Running 'otool -l' on file:\n ${lib}\nfailed:\n${err}") + return() +endif() + +foreach(ver + [[current version 3\.2\.1]] + [[compatibility version 2\.1\.0]] + ) + if(NOT "${out}" MATCHES "( |\n)${ver}( |\n)") + set(RunCMake_TEST_FAILED "Library file:\n ${lib}\ndoes not contain '${ver}'") + return() + endif() +endforeach() diff --git a/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake b/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake new file mode 100644 index 0000000..629e445 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/MacOSVersions.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +add_library(foo SHARED foo.c) +set_target_properties(foo PROPERTIES + VERSION 1.0 + SOVERSION 1 + OSX_COMPATIBILITY_VERSION 2.1.0 + OSX_CURRENT_VERSION 3.2.1 + ) diff --git a/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake b/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake new file mode 100644 index 0000000..eb7ca48 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +function(run_MacOSVersions) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MacOSVersions-build) + run_cmake(MacOSVersions) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(MacOSVersions-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() + +run_MacOSVersions() diff --git a/Tests/RunCMake/MacOSVersions/foo.c b/Tests/RunCMake/MacOSVersions/foo.c new file mode 100644 index 0000000..c83d856 --- /dev/null +++ b/Tests/RunCMake/MacOSVersions/foo.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 0; +} |