-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
127 lines (107 loc) · 5.5 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
project (LowFive)
cmake_minimum_required (VERSION 3.9)
option (wrapped_mpi "MPI compiler wrapper requires no further MPI libs" OFF)
option (lowfive_python "Build python bindings" ON)
option (lowfive_backward "Use backward-cpp for debugging" ON)
option (lowfive_install_examples "Install examples" OFF)
option (lowfive_caliper "Enable profiling with Caliper" OFF)
# C++17
if (NOT DEFINED CMAKE_CXX_STANDARD)
set (CMAKE_CXX_STANDARD 17)
endif ()
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
# ignore variadic args and other warnings (no other good solution)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-value -Wno-deprecated-declarations")
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
# Default to Release
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif (NOT CMAKE_BUILD_TYPE)
# MPI
if (NOT wrapped_mpi)
find_package (MPI REQUIRED)
set (libraries MPI::MPI_C)
endif ()
# Threads
find_package (Threads)
# DIY
option (build_examples "" OFF)
option (build_tests "" OFF)
add_subdirectory (ext/diy)
set (libraries ${libraries} diy)
# fmt
option (FMT_INSTALL "" OFF)
add_subdirectory (ext/fmt)
set (libraries ${libraries} fmt::fmt)
# spdlog
option (SPDLOG_FMT_EXTERNAL "" ON)
option (SPDLOG_BUILD_EXAMPLE "" OFF)
option (SPDLOG_BUILD_TESTS "" OFF)
add_subdirectory (ext/spdlog)
set (libraries ${libraries} spdlog)
include_directories (ext/spdlog/include)
# HDF5
if (HDF5_LIBRARY AND HDF5_HL_LIBRARY AND Z_LIBRARY)
message ("HDF5_LIBRARY = " ${HDF5_LIBRARY})
message ("HDF5_HL_LIBRARY = " ${HDF5_HL_LIBRARY})
message ("Z_LIBRARY = " ${Z_LIBRARY})
set (HDF5_LIBRARY ${HDF5_HL_LIBRARY} ${HDF5_LIBRARY} ${Z_LIBRARY})
else ()
message ("Looking for HDF5")
#if (NOT APPLE)
# set (HDF5_USE_STATIC_LIBRARIES ON)
#endif ()
find_package (HDF5 REQUIRED COMPONENTS C HL)
message ("HDF5_C_LIBRARIES = " ${HDF5_C_LIBRARIES})
message ("HDF5_HL_LIBRARIES = " ${HDF5_HL_LIBRARIES})
message ("HDF5_C_LIBRARY_hdf5 = " ${HDF5_C_LIBRARY_hdf5})
message ("HDF5_C_LIBRARY_z = " ${HDF5_C_LIBRARY_z})
set (HDF5_LIBRARY ${HDF5_C_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARY_hdf5} ${HDF5_C_LIBRARY_z})
endif ()
#set (libraries ${libraries} ${HDF5_LIBRARY})
include_directories (SYSTEM ${HDF5_INCLUDE_DIR})
if(lowfive_backward)
# backward-cpp
add_subdirectory(ext/backward-cpp)
endif()
# Include dirs
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem")
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include
SYSTEM ${MPI_C_INCLUDE_PATH})
# Libraries
set (libraries
${libraries}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS})
if(lowfive_caliper)
find_package(Caliper REQUIRED)
add_compile_definitions (LOWFIVE_USE_CALIPER)
set (libraries
${libraries}
caliper)
endif()
add_subdirectory (src)
set (libraries ${libraries} lowfive lowfive-dist)
# Testing
# NB testing must be enabled before adding tests subdirectory, otherwise no tests will be found
enable_testing ()
include (CTest)
add_subdirectory (tests)
add_subdirectory (examples)
# Install the headers
file (GLOB DEPLOY_FILES_AND_DIRS "${PROJECT_SOURCE_DIR}/include/*")
foreach (ITEM ${DEPLOY_FILES_AND_DIRS})
if (IS_DIRECTORY "${ITEM}")
list (APPEND DIRS_TO_DEPLOY "${ITEM}")
else ()
list (APPEND FILES_TO_DEPLOY "${ITEM}")
endif ()
endforeach ()
install (FILES ${FILES_TO_DEPLOY} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install (DIRECTORY ${DIRS_TO_DEPLOY} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
if (lowfive_python)
add_subdirectory (ext/pybind11)
add_subdirectory (bindings/python)
endif ()