Fetch3rdParty.cmake 3.06 KB
Newer Older
Philipp Götze's avatar
Philipp Götze committed
1
2
3
4
5
6
7
8
message("===== Fetching 3rd Party Dependencies ================================")
include(FetchContent REQUIRED)
find_package(PkgConfig REQUIRED)

set(THIRD_PARTY_DIR "${PROJECT_BINARY_DIR}/_deps")

# Searching for PMDK ======================================================== #
message(STATUS "Searching for PMDK")
9
10
11
12
13
14
15
find_path(PMDK_INCLUDE_DIR libpmem.h)
pkg_check_modules(PMDK REQUIRED libpmemobj++>=1.5)
set(PMDK_INCLUDE_DIRS ${PMDK_INCLUDE_DIRS} ${PMDK_INCLUDE_DIR})
if(NOT PMDK_INCLUDE_DIRS OR "${PMDK_INCLUDE_DIRS}" STREQUAL "")
  message(FATAL_ERROR "ERROR: libpmem include directory not found.")
endif()
message(STATUS "  libpmem.h found in ${PMDK_INCLUDE_DIRS}")
Philipp Götze's avatar
Philipp Götze committed
16
mark_as_advanced(PMDK_LIBRARIES PMDK_INCLUDE_DIRS)
17

Philipp Götze's avatar
Philipp Götze committed
18
19
20
21
22
# Format ==================================================================== #
FetchContent_Declare(
  fmt
  GIT_REPOSITORY https://github.com/fmtlib/fmt.git
  GIT_TAG        5.3.0
23
)
Philipp Götze's avatar
Philipp Götze committed
24
25
26
27
FetchContent_GetProperties(fmt)
if(NOT fmt_POPULATED)
  message(STATUS "Populating fmt (Format)")
  FetchContent_Populate(fmt)
28
29
30
31
32
33
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_HEADER_ONLY=1")
  file(COPY ${fmt_SOURCE_DIR}/include/fmt/core.h
            ${fmt_SOURCE_DIR}/include/fmt/format-inl.h
            ${fmt_SOURCE_DIR}/include/fmt/format.h
       DESTINATION ${THIRD_PARTY_DIR}/fmt
  )
Philipp Götze's avatar
Philipp Götze committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
endif()



if(BUILD_TEST_CASES)
  # Catch =================================================================== #
  FetchContent_Declare(
    catch
    GIT_REPOSITORY https://github.com/catchorg/Catch2.git
    GIT_TAG        v2.9.1
    )
  FetchContent_GetProperties(catch)
  if(NOT catch_POPULATED)
    message(STATUS "Populating catch")
    FetchContent_Populate(catch)
    set(CATCH_INCLUDE_DIR ${catch_SOURCE_DIR}/single_include/catch2)
    add_library(Catch2::Catch IMPORTED INTERFACE)
    set_property(TARGET Catch2::Catch PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CATCH_INCLUDE_DIR}")
  endif()
endif()



if(BUILD_BENCHMARKS)
  # Google Test ============================================================= #
  #[[
  FetchContent_Declare(
    googletest
    GIT_REPOSITORY https://github.com/google/googletest.git
    GIT_TAG        release-1.8.1
    GIT_SHALLOW    TRUE
  )
  FetchContent_GetProperties(googletest)
  if(NOT googletest_POPULATED)
    message(STATUS "Populating googletest")
    FetchContent_Populate(googletest)
    # add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
  endif()
  ]]
  # Google Benchmark ======================================================== #
  FetchContent_Declare(
    benchmark
    GIT_REPOSITORY https://github.com/google/benchmark.git
    GIT_TAG        v1.5.0
    GIT_SHALLOW    TRUE
    )
  FetchContent_GetProperties(benchmark)
  if(NOT benchmark_POPULATED)
    set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
    set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
    message(STATUS "Populating benchmark (google)")
85
    FetchContent_Populate(benchmark)
Philipp Götze's avatar
Philipp Götze committed
86
87
88
89
90
    add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR} EXCLUDE_FROM_ALL)
  endif()
endif()

message("===== Finished fetching 3rd Party Dependencies =======================")