2021-10-06 16:51:11 -07:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version" )
2020-02-29 15:36:54 -08:00
2020-07-31 12:11:20 -07:00
# Code signing ID on Mac.
2020-04-28 10:34:06 -07:00
# If this is falsey, codesigning is disabled.
2020-07-31 12:11:20 -07:00
# '-' is ad-hoc codesign.
set ( MAC_CODESIGN_ID "" CACHE STRING "Mac code-signing identity" )
2020-02-29 15:36:54 -08:00
# Whether to inject the "get-task-allow" entitlement, which permits debugging
# on the Mac.
2020-03-14 16:11:35 -07:00
set ( MAC_INJECT_GET_TASK_ALLOW ON CACHE BOOL "Inject get-task-allow on Mac" )
2020-02-29 15:36:54 -08:00
2020-09-27 11:35:16 -07:00
# When building a Mac build, it is common for fish to link against a
# pcre2 built for the host platform (e.g. macOS 10.15) while fish wants
2022-01-03 08:08:41 -08:00
# to link for macOS 10.9. This warning would be of interest for releases,
2020-09-27 11:35:16 -07:00
# but is just noise for daily development. Unfortunately it has no flag
# of its own, so suppress all linker warnings in debug builds.
2022-01-03 08:08:41 -08:00
set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -w" )
2020-09-27 11:35:16 -07:00
2020-03-14 16:11:35 -07:00
function ( CODESIGN_ON_MAC target )
2020-04-28 10:34:06 -07:00
if ( ( APPLE ) AND ( MAC_CODESIGN_ID ) )
2020-03-22 11:21:29 +01:00
execute_process ( COMMAND sw_vers "-productVersion" OUTPUT_VARIABLE OSX_VERSION )
2020-03-14 16:11:35 -07:00
if ( MAC_INJECT_GET_TASK_ALLOW )
set ( ENTITLEMENTS "--entitlements" "${CMAKE_SOURCE_DIR}/osx/fish_debug.entitlements" )
else ( )
set ( ENTITLEMENTS "" )
endif ( MAC_INJECT_GET_TASK_ALLOW )
2020-03-22 11:21:29 +01:00
if ( OSX_VERSION VERSION_LESS "10.13.6" )
# `-options runtime` is only available in OS X from 10.13.6 and up
add_custom_command (
T A R G E T $ { t a r g e t }
P O S T _ B U I L D
C O M M A N D c o d e s i g n - - f o r c e - - d e e p $ { E N T I T L E M E N T S } - - s i g n " $ { M A C _ C O D E S I G N _ I D } " $ < T A R G E T _ F I L E : $ { t a r g e t } >
V E R B A T I M
)
else ( )
add_custom_command (
T A R G E T $ { t a r g e t }
P O S T _ B U I L D
C O M M A N D c o d e s i g n - - f o r c e - - d e e p - - o p t i o n s r u n t i m e $ { E N T I T L E M E N T S } - - s i g n " $ { M A C _ C O D E S I G N _ I D } " $ < T A R G E T _ F I L E : $ { t a r g e t } >
V E R B A T I M
)
endif ( )
2020-03-14 16:11:35 -07:00
endif ( )
endfunction ( CODESIGN_ON_MAC target )