Skip to content

Commit

Permalink
Merge pull request ceph#27089 from tchaikov/wip-cmake-with-ninja
Browse files Browse the repository at this point in the history
cmake: do not assume ${CMAKE_GENERATOR} == make

Reviewed-by: Casey Bodley <[email protected]>
  • Loading branch information
tchaikov authored Mar 21, 2019
2 parents 9663480 + a0c6fb9 commit 085fdf5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
14 changes: 11 additions & 3 deletions cmake/modules/BuildDPDK.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function(do_build_dpdk dpdk_dir)
find_program (MAKE_EXECUTABLE NAMES make gmake)
# mk/machine/native/rte.vars.mk
# rte_cflags are extracted from mk/machine/${machine}/rte.vars.mk
# only 3 of them have -march=<arch> defined, so copying them here.
Expand Down Expand Up @@ -59,7 +60,7 @@ function(do_build_dpdk dpdk_dir)
set(target "${arch}-${machine_tmpl}-${execenv}-${toolchain}")

execute_process(
COMMAND ${CMAKE_MAKE_PROGRAM} showconfigs
COMMAND ${MAKE_EXECUTABLE} showconfigs
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/spdk/dpdk
OUTPUT_VARIABLE supported_targets
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -71,11 +72,18 @@ function(do_build_dpdk dpdk_dir)
"\"${target}\" not listed in ${supported_targets}")
endif()

if(CMAKE_MAKE_PROGRAM MATCHES "make")
# try to inherit command line arguments passed by parent "make" job
set(make_cmd "$(MAKE)")
else()
set(make_cmd "${MAKE_EXECUTABLE}")
endif()

include(ExternalProject)
ExternalProject_Add(dpdk-ext
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/spdk/dpdk
CONFIGURE_COMMAND $(MAKE) config O=${dpdk_dir} T=${target}
BUILD_COMMAND env CC=${CMAKE_C_COMPILER} $(MAKE) O=${dpdk_dir} EXTRA_CFLAGS=-fPIC
CONFIGURE_COMMAND ${make_cmd} config O=${dpdk_dir} T=${target}
BUILD_COMMAND env CC=${CMAKE_C_COMPILER} ${make_cmd} O=${dpdk_dir} EXTRA_CFLAGS=-fPIC
BUILD_IN_SOURCE 1
INSTALL_COMMAND "true")
ExternalProject_Add_Step(dpdk-ext patch-config
Expand Down
3 changes: 2 additions & 1 deletion cmake/modules/BuildRocksDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function(build_rocksdb)
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
list(APPEND rocksdb_CMAKE_ARGS -DFAIL_ON_WARNINGS=OFF)
list(APPEND rocksdb_CMAKE_ARGS -DUSE_RTTI=1)
list(APPEND rocksdb_CMAKE_ARGS -G${CMAKE_GENERATOR})
CHECK_C_COMPILER_FLAG("-Wno-stringop-truncation" HAS_WARNING_STRINGOP_TRUNCATION)
if(HAS_WARNING_STRINGOP_TRUNCATION)
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_C_FLAGS="-Wno-stringop-truncation")
Expand All @@ -52,7 +53,7 @@ function(build_rocksdb)
SOURCE_DIR "${rocksdb_SOURCE_DIR}"
CMAKE_ARGS ${rocksdb_CMAKE_ARGS}
BINARY_DIR "${rocksdb_BINARY_DIR}"
BUILD_COMMAND $(MAKE) rocksdb
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target rocksdb
INSTALL_COMMAND "true")
# force rocksdb make to be called on each time
ExternalProject_Add_Step(rocksdb_ext forcebuild
Expand Down
12 changes: 11 additions & 1 deletion cmake/modules/BuildSPDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ macro(build_spdk)
find_package(aio REQUIRED)
find_package(uuid REQUIRED)
endif()

find_program (MAKE_EXECUTABLE NAMES make gmake)
if(CMAKE_MAKE_PROGRAM MATCHES "make")
# try to inherit command line arguments passed by parent "make" job
set(make_cmd "$(MAKE)")
else()
set(make_cmd "${MAKE_EXECUTABLE}")
endif()

include(ExternalProject)
ExternalProject_Add(spdk-ext
DEPENDS dpdk-ext
Expand All @@ -17,9 +26,10 @@ macro(build_spdk)
# unset $CFLAGS, otherwise it will interfere with how SPDK sets
# its include directory.
# unset $LDFLAGS, otherwise SPDK will fail to mock some functions.
BUILD_COMMAND env -i PATH=$ENV{PATH} CC=${CMAKE_C_COMPILER} $(MAKE) EXTRA_CFLAGS="-fPIC"
BUILD_COMMAND env -i PATH=$ENV{PATH} CC=${CMAKE_C_COMPILER} ${make_cmd} EXTRA_CFLAGS="-fPIC"
BUILD_IN_SOURCE 1
INSTALL_COMMAND "true")
unset(make_cmd)
ExternalProject_Get_Property(spdk-ext source_dir)
foreach(c nvme log lvol env_dpdk util)
add_library(spdk::${c} STATIC IMPORTED)
Expand Down
3 changes: 2 additions & 1 deletion src/compressor/zstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ ExternalProject_Add(zstd_ext
-DCMAKE_C_FLAGS=${ZSTD_C_FLAGS}
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_POSITION_INDEPENDENT_CODE=${ENABLE_SHARED}
-G${CMAKE_GENERATOR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libzstd
BUILD_COMMAND $(MAKE) libzstd_static
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target libzstd_static
INSTALL_COMMAND "true")

# force zstd make to be called on each time
Expand Down

0 comments on commit 085fdf5

Please sign in to comment.