Greatly simplify deployment target handling

This commit is contained in:
William Kent
2024-09-11 11:26:08 -04:00
parent 321e6f0a8b
commit 43aac4119b
2 changed files with 2 additions and 26 deletions

View File

@@ -15,14 +15,8 @@ function(add_darwin_executable name)
# TODO: Handle SL_NO_STANDARD_LIBRARIES here, once the libraries have been added to the build.
if(SL_MACOSX_VERSION_MIN)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${SL_MACOSX_VERSION_MIN})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
target_link_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${SL_MACOSX_VERSION_MIN})
elseif(CMAKE_MACOSX_MIN_VERSION)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${CMAKE_MACOSX_MIN_VERSION})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
target_link_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_MACOSX_MIN_VERSION})
else()
message(AUTHOR_WARNING "Could not determine -mmacosx-version-min flag for target ${name}")
@@ -37,9 +31,9 @@ function(add_darwin_static_library name)
target_compile_definitions(${name} PRIVATE __PUREDARWIN__)
if(SL_MACOSX_VERSION_MIN)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${SL_MACOSX_VERSION_MIN})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${SL_MACOSX_VERSION_MIN})
elseif(CMAKE_MACOSX_MIN_VERSION)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${CMAKE_MACOSX_MIN_VERSION})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_MACOSX_MIN_VERSION})
else()
message(AUTHOR_WARNING "Could not determine -mmacosx-version-min flag for target ${name}")
endif()
@@ -79,14 +73,8 @@ function(add_darwin_shared_library name)
endif()
if(SL_MACOSX_VERSION_MIN)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${SL_MACOSX_VERSION_MIN})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
target_link_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${SL_MACOSX_VERSION_MIN})
elseif(CMAKE_MACOSX_MIN_VERSION)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${CMAKE_MACOSX_MIN_VERSION})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
target_link_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_MACOSX_MIN_VERSION})
else()
message(AUTHOR_WARNING "Could not determine -mmacosx-version-min flag for target ${name}")
@@ -117,14 +105,8 @@ function(add_darwin_object_library name)
target_compile_definitions(${name} PRIVATE __PUREDARWIN__)
if(SL_MACOSX_VERSION_MIN)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${SL_MACOSX_VERSION_MIN})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
target_link_options(${name} PRIVATE -mmacosx-version-min=${SL_MACOSX_VERSION_MIN})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${SL_MACOSX_VERSION_MIN})
elseif(CMAKE_MACOSX_MIN_VERSION)
target_compile_options(${name} PRIVATE -target x86_64-apple-macos${CMAKE_MACOSX_MIN_VERSION})
target_compile_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
target_link_options(${name} PRIVATE -mmacosx-version-min=${CMAKE_MACOSX_MIN_VERSION})
set_property(TARGET ${name} PROPERTY CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_MACOSX_MIN_VERSION})
else()
message(AUTHOR_WARNING "Could not determine -mmacosx-version-min flag for target ${name}")

View File

@@ -1,9 +1,3 @@
# CMake 3.27 insists on passing an mmacosx-version-min flag for every C/C++
# file compiled on the macOS platform. We use -target to specify the version
# of macOS we're targeting. With modern clang, this results in a warning on
# every C file. Don't do this.
add_compile_options(-Wno-overriding-t-option)
# This warning is emitted by Clang for no good reason, given that it doesn't
# impact compilation in any way, and produces a lot of log spam.
add_compile_options(-Wno-undef-prefix)