-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
65 lines (52 loc) · 2 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
cmake_minimum_required(VERSION 3.11)
project(nemo)
# Set build type to RELEASE by default:
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type provided, default to RELEASE.")
set(CMAKE_BUILD_TYPE "RELEASE")
endif()
# Options can be turned on and off by providing cmake with a -DOPTIONNAME=ON (or OFF) argument.
# For example, to turn off benchmarks, build a shared library, and use sanitize flags in a DEBUG build:
# cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DNEMO_BENCH=OFF -DBENCH_STATIC=OFF -DNEMO_SANITIZE=ON
option(NEMO_TEST "Build tests" ON)
option(NEMO_BENCH "Build benchmarks" ON)
option(NEMO_STATIC "Builds a static library instead of a shared one" OFF)
option(NEMO_SANITIZE "Adds sanitive flags" OFF)
if(NEMO_STATIC)
set(NEMO_LIB_NAME nemo_static)
set(NEMO_LIB_TYPE STATIC)
else()
set(NEMO_LIB_NAME nemo)
set(NEMO_LIB_TYPE SHARED)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Threads REQUIRED)
find_package(Boost)
find_package(MATH)
include(FetchContent)
include_directories(. include ${Boost_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NEMO_SANITIZE)
set(CMAKE_CXX_FLAGS "-fsanitize=address -fsanitize=undefined ${CMAKE_CXX_FLAGS}")
endif()
add_subdirectory(src)
if(NEMO_TEST)
enable_testing()
add_subdirectory(test)
endif()
if(NEMO_BENCH)
add_subdirectory(bench)
endif()
message(STATUS "")
message(STATUS "BUILD SUMMARY")
message(STATUS " CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS " Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Library name : ${NEMO_LIB_NAME}")
message(STATUS " Library type : ${NEMO_LIB_TYPE}")
message(STATUS " Build tests : ${NEMO_TEST}")
message(STATUS " Build benchmarks : ${NEMO_BENCH}")
message(STATUS " Sanitize flags : ${NEMO_SANITIZE}")
message(STATUS " Boost include dirs : ${Boost_INCLUDE_DIRS}")
message(STATUS "")