You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by tw...@apache.org on 2022/06/29 15:32:05 UTC
[incubator-kvrocks] branch unstable updated: Forward C compiler to build deps in CMake (#692)
This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new bf3287c Forward C compiler to build deps in CMake (#692)
bf3287c is described below
commit bf3287cad4dee6b6c50f92aaaa2521744325a655
Author: Twice <tw...@gmail.com>
AuthorDate: Wed Jun 29 23:32:00 2022 +0800
Forward C compiler to build deps in CMake (#692)
In this PR, we make sure that those C dependencies with makefiles or automake is compiled by the compiler specified by `CMAKE_C_COMPILER`.
---
build.sh | 6 +++++-
cmake/jemalloc.cmake | 2 +-
cmake/lz4.cmake | 7 ++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/build.sh b/build.sh
index 97f68c8..de3026d 100755
--- a/build.sh
+++ b/build.sh
@@ -26,6 +26,8 @@ function usage() {
echo "-jN : execute N build jobs concurrently, default N = 4" >&2
echo "--unittest : build unittest target" >&2
echo "--ninja : use ninja to build kvrocks" >&2
+ echo "--gcc : use gcc/g++ to build kvrocks" >&2
+ echo "--clang : use clang/clang++ to build kvrocks" >&2
echo "--ghproxy : use ghproxy.com to fetch dependencies" >&2
echo "-h, --help : print this help messages" >&2
exit 1
@@ -36,6 +38,8 @@ until [ $# -eq 0 ]; do
-D*) CMAKE_DEFS="$CMAKE_DEFS $1";;
--unittest) BUILD_UNITTEST=1;;
--ninja) USE_NINJA="-G Ninja";;
+ --gcc) COMPILER="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++";;
+ --clang) COMPILER="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++";;
--ghproxy) USE_GHPROXY="-DDEPS_FETCH_PROXY=https://ghproxy.com/";;
-j*) JOB_CMD=$1;;
-*) usage;;
@@ -99,7 +103,7 @@ mkdir -p $BUILD_DIR
cd $BUILD_DIR
set -x
-$CMAKE_BIN $WORKING_DIR -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_DEFS $USE_NINJA $USE_GHPROXY
+$CMAKE_BIN $WORKING_DIR -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_DEFS $USE_NINJA $COMPILER $USE_GHPROXY
$CMAKE_BIN --build . $JOB_CMD -t kvrocks kvrocks2redis
if [ -n "$BUILD_UNITTEST" ]; then
diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake
index e8c3198..ee06442 100644
--- a/cmake/jemalloc.cmake
+++ b/cmake/jemalloc.cmake
@@ -31,7 +31,7 @@ if(NOT jemalloc_POPULATED)
execute_process(COMMAND autoconf
WORKING_DIRECTORY ${jemalloc_SOURCE_DIR}
)
- execute_process(COMMAND ${jemalloc_SOURCE_DIR}/configure -C --enable-autogen --disable-libdl --with-jemalloc-prefix=""
+ execute_process(COMMAND ${jemalloc_SOURCE_DIR}/configure CC=${CMAKE_C_COMPILER} -C --enable-autogen --disable-libdl --with-jemalloc-prefix=""
WORKING_DIRECTORY ${jemalloc_BINARY_DIR}
)
add_custom_target(make_jemalloc
diff --git a/cmake/lz4.cmake b/cmake/lz4.cmake
index d3cc5b9..03880ff 100644
--- a/cmake/lz4.cmake
+++ b/cmake/lz4.cmake
@@ -27,7 +27,12 @@ FetchContent_DeclareGitHubWithMirror(lz4
FetchContent_GetProperties(lz4)
if(NOT lz4_POPULATED)
FetchContent_Populate(lz4)
- add_custom_target(make_lz4 COMMAND make liblz4.a
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+ set(APPLE_FLAG "CFLAGS=-isysroot ${CMAKE_OSX_SYSROOT}")
+ endif()
+
+ add_custom_target(make_lz4 COMMAND make CC=${CMAKE_C_COMPILER} ${APPLE_FLAG} liblz4.a
WORKING_DIRECTORY ${lz4_SOURCE_DIR}/lib
BYPRODUCTS ${lz4_SOURCE_DIR}/lib/liblz4.a
)