From bb5704f3a6068bad4ead318de3728e03ccb78bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 4 Sep 2024 13:04:35 +0200 Subject: [PATCH] cmake: Improve blst build on macOS --- cmake/blst.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/blst.cmake b/cmake/blst.cmake index 52e15439dc..2ccf3f04e8 100644 --- a/cmake/blst.cmake +++ b/cmake/blst.cmake @@ -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()