mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
16fd07244d
since we are moving the test nodes from bionic to focal, we are able to use the prebuilt libzstd libraries when running "make check". to speed up the build and test, in this change: * add FindZstd.cmake which allows us to use the libzstd in system * extract BuildZstd.cmake for better readability * add an option named "WITH_SYSTEM_ZSTD", which defaults to "OFF", so user can enable it on demand. Signed-off-by: Kefu Chai <kchai@redhat.com>
23 lines
998 B
CMake
23 lines
998 B
CMake
# libzstd - build it statically
|
|
function(build_Zstd)
|
|
set(ZSTD_C_FLAGS "-fPIC -Wno-unused-variable -O3")
|
|
|
|
include(ExternalProject)
|
|
ExternalProject_Add(zstd_ext
|
|
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/zstd/build/cmake
|
|
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
-DCMAKE_C_FLAGS=${ZSTD_C_FLAGS}
|
|
-DCMAKE_AR=${CMAKE_AR}
|
|
-DCMAKE_POSITION_INDEPENDENT_CODE=${ENABLE_SHARED}
|
|
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libzstd
|
|
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target libzstd_static
|
|
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/libzstd/lib/libzstd.a"
|
|
INSTALL_COMMAND "")
|
|
add_library(Zstd::Zstd STATIC IMPORTED)
|
|
set_target_properties(Zstd::Zstd PROPERTIES
|
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/src/zstd/lib"
|
|
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libzstd/lib/libzstd.a")
|
|
add_dependencies(Zstd::Zstd zstd_ext)
|
|
endfunction()
|