Skip to content

Commit

Permalink
fix cross compilation
Browse files Browse the repository at this point in the history
see helium/erlang-pbc#15 for details
  • Loading branch information
Benoit Duffez authored and JayKickliter committed Mar 8, 2021
1 parent f8f9a80 commit 663ff1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 5 additions & 1 deletion c_src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
##########################################################################
# Project Setup #
##########################################################################
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.11)
project(ErlangErasure C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 99)

list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
include(ASan)

if(DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
endif()

IF (APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "-flat_namespace -undefined suppress")
set(CMAKE_MACOSX_RPATH 1)
Expand Down
9 changes: 7 additions & 2 deletions c_src/cmake/FindGFComplete.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UC)
endif()

set(CONFIGURE_ARGS $ENV{CONFIGURE_ARGS})
separate_arguments(CONFIGURE_ARGS)

set(CONFIGURE_CFLAGS "$ENV{CFLAGS} ${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}")

ExternalProject_Add(gf-complete
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gf-complete
GIT_REPOSITORY https://github.com/ceph/gf-complete.git
Expand All @@ -16,9 +21,9 @@ ExternalProject_Add(gf-complete
--prefix=${CMAKE_CURRENT_BINARY_DIR}
--with-pic
--disable-shared
$ENV{CONFIGURE_ARGS}
${CONFIGURE_ARGS}
CC=${CMAKE_C_COMPILER}
CFLAGS=${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}
CFLAGS=${CONFIGURE_CFLAGS}
${GF_APPLE_ENV}
BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j ${GF_APPLE_ENV}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/lib/libgf_complete.a
Expand Down
12 changes: 9 additions & 3 deletions c_src/cmake/FindJerasure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UC)
endif()

set(CONFIGURE_ARGS $ENV{CONFIGURE_ARGS})
separate_arguments(CONFIGURE_ARGS)

set(CONFIGURE_CFLAGS "$ENV{CFLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}")
set(CONFIGURE_LDFLAGS "$ENV{LDFLAGS} -L${CMAKE_CURRENT_BINARY_DIR}/lib")

ExternalProject_Add(jerasure
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/jerasure
GIT_REPOSITORY http://github.com/ceph/jerasure.git
Expand All @@ -19,10 +25,10 @@ ExternalProject_Add(jerasure
--prefix=${CMAKE_CURRENT_BINARY_DIR}
--with-pic
--disable-shared
$ENV{CONFIGURE_ARGS}
${CONFIGURE_ARGS}
CC=${CMAKE_C_COMPILER}
"CFLAGS=-I${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_C_FLAGS_${BUILD_TYPE_UC}}"
LDFLAGS=-L${CMAKE_CURRENT_BINARY_DIR}/lib
CFLAGS=${CONFIGURE_CFLAGS}
LDFLAGS=${CONFIGURE_LDFLAGS}
${GF_APPLE_ENV}
BUILD_COMMAND ${CMAKE_BUILD_TOOL} -j ${GF_APPLE_ENV}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/lib/libJerasure.a
Expand Down

0 comments on commit 663ff1e

Please sign in to comment.