From 4924b08805cc0a76d07ecf269463f1977816f150 Mon Sep 17 00:00:00 2001 From: Jeremy Cooper Date: Tue, 23 Feb 2021 12:19:57 -0800 Subject: [PATCH] Fix builds for Mac OS X and CMake. Fix builds for Mac OS X hosts using a method that JayKickliter and I derived while researching this current problem with CMake. In the future, CMake will probably come up with some reasonable defaults that update CFLAGS properly on Mac OS X so that it gets the proper `-isysroot ` that is sorely needed when invoking `clang` as directly as CMake is doing. --- c_src/cmake/FindGFComplete.cmake | 11 ++++++++++- c_src/cmake/FindJerasure.cmake | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/c_src/cmake/FindGFComplete.cmake b/c_src/cmake/FindGFComplete.cmake index 263c225..bf106ad 100644 --- a/c_src/cmake/FindGFComplete.cmake +++ b/c_src/cmake/FindGFComplete.cmake @@ -5,6 +5,14 @@ if(CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UC) endif() +if (APPLE) + execute_process(COMMAND + xcrun --show-sdk-path + OUTPUT_VARIABLE APPLE_SDK_ROOT + ) + set(GF_APPLE_ENV "SDKROOT=${APPLE_SDK_ROOT}") +endif() + ExternalProject_Add(gf-complete PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gf-complete GIT_REPOSITORY https://github.com/ceph/gf-complete.git @@ -19,7 +27,8 @@ ExternalProject_Add(gf-complete $ENV{CONFIGURE_ARGS} CC=${CMAKE_C_COMPILER} CFLAGS=${CMAKE_C_FLAGS_${BUILD_TYPE_UC}} - BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j + ${GF_APPLE_ENV} + BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j ${GF_APPLE_ENV} BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/lib/libgf_complete.a INSTALL_COMMAND ${CMAKE_BUILD_TOOL} install ) diff --git a/c_src/cmake/FindJerasure.cmake b/c_src/cmake/FindJerasure.cmake index c0aa084..9585ddb 100644 --- a/c_src/cmake/FindJerasure.cmake +++ b/c_src/cmake/FindJerasure.cmake @@ -8,6 +8,14 @@ if(CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UC) endif() +if (APPLE) + execute_process(COMMAND + xcrun --show-sdk-path + OUTPUT_VARIABLE APPLE_SDK_ROOT + ) + set(GF_APPLE_ENV "SDKROOT=${APPLE_SDK_ROOT}") +endif() + ExternalProject_Add(jerasure PREFIX ${CMAKE_CURRENT_BINARY_DIR}/jerasure GIT_REPOSITORY http://github.com/ceph/jerasure.git @@ -23,7 +31,8 @@ ExternalProject_Add(jerasure CC=${CMAKE_C_COMPILER} "CFLAGS=-I${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}" LDFLAGS=-L${CMAKE_CURRENT_BINARY_DIR}/lib - BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j + ${GF_APPLE_ENV} + BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j ${GF_APPLE_ENV} BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/lib/libJerasure.a INSTALL_COMMAND ${CMAKE_BUILD_TOOL} install )