Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set the env MACOSX_DEPLOYMENT_TARGET to the current macOS version unless the env is already set #1250

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions cmake/luajit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,42 @@ include_guard()

include(cmake/utils.cmake)

if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET))
if ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET))
set(SW_CMD "sw_vers")
set(SW_CMD_ARG "-productVersion")
execute_process(COMMAND ${SW_CMD} ${SW_CMD_ARG}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE SW_CMD_OUTPUT
RESULT_VARIABLE SW_CMD_STATUS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (SW_CMD_STATUS EQUAL 0)
string(REGEX MATCH "[0-9]+.[0-9]+"
DEPLOYMENT_TARGET ${SW_CMD_OUTPUT})
set(CMAKE_OSX_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET was set to: ${DEPLOYMENT_TARGET}")
endif ()
endif ()

if ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET))
message(FATAL_ERROR "The CMake option `CMAKE_OSX_DEPLOYMENT_TARGET` need to be specified, e.g. `-DCMAKE_OSX_DEPLOYMENT_TARGET=10.3`")
endif()
endif ()

FetchContent_DeclareGitHubWithMirror(luajit
KvrocksLabs/LuaJIT b80ea0e44bd259646d988324619612f645e4b637
MD5=f9566c424fb57b226066e3a39a10ec8d
)
KvrocksLabs/LuaJIT b80ea0e44bd259646d988324619612f645e4b637
MD5=f9566c424fb57b226066e3a39a10ec8d)

FetchContent_GetProperties(luajit)
if(NOT lua_POPULATED)
if (NOT lua_POPULATED)
FetchContent_Populate(luajit)

set(LUA_CFLAGS "-DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC= -DLUA_USE_MKSTEMP")
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(LUA_CFLAGS "${LUA_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
endif ()

if (CMAKE_HOST_APPLE)
set(MACOSX_TARGET "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
endif ()

add_custom_target(make_luajit COMMAND make libluajit.a
"CFLAGS=${LUA_CFLAGS}" ${MACOSX_TARGET}
Expand Down