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

cmake: Improve blst build on macOS #986

Merged
merged 1 commit into from
Sep 5, 2024
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
19 changes: 13 additions & 6 deletions cmake/blst.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ include(ExternalProject)

if(MSVC)
set(BLST_BUILD_SCRIPT build.bat)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Don't pass CC to the script because it doesn't work.
set(BLST_BUILD_SCRIPT ./build.sh -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
else()
# Pass CC and AR, this supports cross-compilation.
# Pass CFLAGS as part of CC (e.g. to pass -m32). Using CFLAGS directly overwrites blst's default.
string(JOIN " " BLST_CC ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS})
# Build CC compiler invocation.
set(BLST_CC ${CMAKE_C_COMPILER})
if(CMAKE_OSX_SYSROOT)
set(BLST_CC "${BLST_CC} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}")
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET)
set(BLST_CC "${BLST_CC} ${CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
if(CMAKE_C_FLAGS)
# Pass CFLAGS as part of CC (e.g. to pass -m32). Using CFLAGS directly overwrites blst's default.
set(BLST_CC "${BLST_CC} ${CMAKE_C_FLAGS}")
endif()

set(BLST_BUILD_SCRIPT ./build.sh CC='${BLST_CC}' AR='${CMAKE_AR}')
endif()

Expand Down