2022-06-24 16:11:18 +00:00
|
|
|
function(build_pmdk enable_ndctl)
|
2021-04-14 05:20:17 +00:00
|
|
|
include(FindMake)
|
|
|
|
find_make("MAKE_EXECUTABLE" "make_cmd")
|
|
|
|
|
|
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/src/pmdk/Makefile")
|
|
|
|
set(source_dir_args
|
|
|
|
SOURCE_DIR "${PROJECT_SOURCE_DIR}/src/pmdk")
|
|
|
|
else()
|
|
|
|
set(source_dir_args
|
|
|
|
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/pmdk
|
|
|
|
GIT_REPOSITORY https://github.com/ceph/pmdk.git
|
2021-01-29 02:05:53 +00:00
|
|
|
GIT_TAG "1.10"
|
2021-04-14 05:20:17 +00:00
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
GIT_CONFIG advice.detachedHead=false)
|
|
|
|
endif()
|
2019-07-10 15:20:48 +00:00
|
|
|
|
2022-06-24 16:11:18 +00:00
|
|
|
set(LIBPMEM_INTERFACE_LINK_LIBRARIES Threads::Threads)
|
|
|
|
if(${enable_ndctl})
|
|
|
|
set(ndctl "y")
|
|
|
|
list(APPEND LIBPMEM_INTERFACE_LINK_LIBRARIES ndctl::ndctl daxctl::daxctl)
|
|
|
|
else()
|
|
|
|
set(ndctl "n")
|
|
|
|
endif()
|
|
|
|
|
2019-07-10 15:20:48 +00:00
|
|
|
# Use debug PMDK libs in debug lib/rbd builds
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
set(PMDK_LIB_DIR "debug")
|
|
|
|
else()
|
|
|
|
set(PMDK_LIB_DIR "nondebug")
|
|
|
|
endif()
|
2020-04-02 04:15:21 +00:00
|
|
|
|
2022-08-04 05:09:11 +00:00
|
|
|
set(pmdk_cflags "-Wno-error -fno-lto")
|
2021-04-14 05:20:17 +00:00
|
|
|
include(ExternalProject)
|
2020-01-17 15:51:18 +00:00
|
|
|
ExternalProject_Add(pmdk_ext
|
2021-04-14 05:20:17 +00:00
|
|
|
${source_dir_args}
|
2019-07-10 15:20:48 +00:00
|
|
|
CONFIGURE_COMMAND ""
|
2022-08-04 05:09:11 +00:00
|
|
|
BUILD_COMMAND ${make_cmd} CC=${CMAKE_C_COMPILER} "EXTRA_CFLAGS=${pmdk_cflags}" NDCTL_ENABLE=${ndctl} BUILD_EXAMPLES=n BUILD_BENCHMARKS=n DOC=n
|
2019-07-10 15:20:48 +00:00
|
|
|
BUILD_IN_SOURCE 1
|
2021-04-14 05:20:17 +00:00
|
|
|
BUILD_BYPRODUCTS "<SOURCE_DIR>/src/${PMDK_LIB_DIR}/libpmem.a" "<SOURCE_DIR>/src/${PMDK_LIB_DIR}/libpmemobj.a"
|
2021-03-04 07:16:37 +00:00
|
|
|
INSTALL_COMMAND "")
|
2021-04-14 05:20:17 +00:00
|
|
|
unset(make_cmd)
|
|
|
|
|
|
|
|
ExternalProject_Get_Property(pmdk_ext source_dir)
|
|
|
|
set(PMDK_SRC "${source_dir}/src")
|
|
|
|
set(PMDK_INCLUDE "${source_dir}/src/include")
|
|
|
|
set(PMDK_LIB "${source_dir}/src/${PMDK_LIB_DIR}")
|
2019-07-10 15:20:48 +00:00
|
|
|
|
2020-04-02 04:36:34 +00:00
|
|
|
# libpmem
|
2022-06-25 09:43:52 +00:00
|
|
|
add_library(pmdk::pmem STATIC IMPORTED GLOBAL)
|
|
|
|
add_dependencies(pmdk::pmem pmdk_ext)
|
2020-04-02 04:36:34 +00:00
|
|
|
file(MAKE_DIRECTORY ${PMDK_INCLUDE})
|
2021-08-20 14:44:39 +00:00
|
|
|
find_package(Threads)
|
2022-06-25 09:43:52 +00:00
|
|
|
set_target_properties(pmdk::pmem PROPERTIES
|
2020-04-02 04:36:34 +00:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${PMDK_INCLUDE}
|
|
|
|
IMPORTED_LOCATION "${PMDK_LIB}/libpmem.a"
|
2022-06-24 16:11:18 +00:00
|
|
|
INTERFACE_LINK_LIBRARIES "${LIBPMEM_INTERFACE_LINK_LIBRARIES}")
|
2019-07-10 15:20:48 +00:00
|
|
|
|
2020-04-02 04:36:34 +00:00
|
|
|
# libpmemobj
|
2022-06-25 09:43:52 +00:00
|
|
|
add_library(pmdk::pmemobj STATIC IMPORTED GLOBAL)
|
|
|
|
add_dependencies(pmdk::pmemobj pmdk_ext)
|
|
|
|
set_target_properties(pmdk::pmemobj PROPERTIES
|
2020-04-02 04:36:34 +00:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${PMDK_INCLUDE}
|
|
|
|
IMPORTED_LOCATION "${PMDK_LIB}/libpmemobj.a"
|
2022-06-25 09:43:52 +00:00
|
|
|
INTERFACE_LINK_LIBRARIES "pmdk::pmem;${CMAKE_THREAD_LIBS_INIT}")
|
2019-07-10 15:20:48 +00:00
|
|
|
endfunction()
|