mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
macOS: Test OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties
Issue: #17652
This commit is contained in:
@@ -305,6 +305,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)
|
||||
|
||||
3
Tests/RunCMake/MacOSVersions/CMakeLists.txt
Normal file
3
Tests/RunCMake/MacOSVersions/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
27
Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake
Normal file
27
Tests/RunCMake/MacOSVersions/MacOSVersions-build-check.cmake
Normal file
@@ -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()
|
||||
9
Tests/RunCMake/MacOSVersions/MacOSVersions.cmake
Normal file
9
Tests/RunCMake/MacOSVersions/MacOSVersions.cmake
Normal file
@@ -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
|
||||
)
|
||||
11
Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake
Normal file
11
Tests/RunCMake/MacOSVersions/RunCMakeTest.cmake
Normal file
@@ -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()
|
||||
4
Tests/RunCMake/MacOSVersions/foo.c
Normal file
4
Tests/RunCMake/MacOSVersions/foo.c
Normal file
@@ -0,0 +1,4 @@
|
||||
int foo(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user