generated from mochi-hpc/thallium-microservice-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
107 lines (96 loc) · 3.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# (C) 2023 The University of Chicago
# See COPYRIGHT in top-level directory.
cmake_minimum_required (VERSION 3.15)
project (warabi C CXX)
set (CMAKE_CXX_STANDARD 17)
enable_testing ()
# library version set here (e.g. for shared libs).
set (WARABI_VERSION_MAJOR 0)
set (WARABI_VERSION_MINOR 6)
set (WARABI_VERSION_PATCH 1)
set (WARABI_VERSION
"${WARABI_VERSION_MAJOR}.${WARABI_VERSION_MINOR}.${WARABI_VERSION_PATCH}")
add_definitions (-Wextra -Wall -Wpedantic)
add_library (coverage_config INTERFACE)
option (ENABLE_TESTS "Build tests" OFF)
option (ENABLE_EXAMPLES "Build examples" OFF)
option (ENABLE_BEDROCK "Build bedrock module" OFF)
option (ENABLE_COVERAGE "Build with coverage" OFF)
option (ENABLE_REMI "Build with REMI support" OFF)
option (ENABLE_PYTHON "Build with Python support" OFF)
# add our cmake module directory to the path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# link shared lib with full rpath
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# setup cache variables for ccmake
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release
CACHE STRING "Choose the type of build." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif ()
set (CMAKE_PREFIX_PATH "" CACHE STRING "External dependencies path")
set (BUILD_SHARED_LIBS "ON" CACHE BOOL "Build a shared library")
if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options (coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options (coverage_config INTERFACE --coverage)
else ()
target_link_libraries (coverage_config INTERFACE --coverage)
endif ()
endif ()
find_package (PkgConfig REQUIRED)
# search fo thallium
find_package (thallium REQUIRED)
# search for nlohmann/json and the validator library
find_package (nlohmann_json REQUIRED)
find_package (nlohmann_json_schema_validator REQUIRED)
# search for TCLAP
find_package (TCLAP REQUIRED)
# search for spdlog
find_package (spdlog REQUIRED)
# search for fmt
find_package (fmt REQUIRED)
# search for libpmemobj
pkg_check_modules (libpmemobj REQUIRED IMPORTED_TARGET libpmemobj)
# search for abt-io
pkg_check_modules (abt-io REQUIRED IMPORTED_TARGET abt-io)
# search of bedrock if needed
if (${ENABLE_BEDROCK})
find_package (bedrock-module-api REQUIRED)
endif ()
if (${ENABLE_REMI})
find_package (remi REQUIRED)
set (WARABI_HAS_REMI ON)
else ()
set (WARABI_HAS_REMI OFF)
endif ()
if (ENABLE_PYTHON)
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
# find_package (pybind11 REQUIRED)
add_subdirectory (python)
endif ()
add_subdirectory (src)
if (${ENABLE_TESTS})
enable_testing ()
find_package (Catch2 3.6.0 QUIET)
if (NOT Catch2_FOUND)
include (FetchContent)
FetchContent_Declare (
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.6.0
)
FetchContent_MakeAvailable (Catch2)
endif ()
add_subdirectory (tests)
endif (${ENABLE_TESTS})
if (${ENABLE_EXAMPLES})
add_subdirectory (examples)
endif (${ENABLE_EXAMPLES})