-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (44 loc) · 1.74 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
# CMakeLists.txt (root directory)
cmake_minimum_required(VERSION 3.10)
project(MOC_Solver)
# define C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Define build types
set(CMAKE_CONFIGURATION_TYPES "Release;Dev" CACHE STRING "" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Dev)
endif()
# default build type is Dev
option(ENABLE_LOGGING "Enable logging" ON)
if(NOT ENABLE_LOGGING)
add_definitions(-DDISABLE_LOGGING)
endif()
# find OpenMP
find_package(OpenMP REQUIRED)
if(NOT OpenMP_FOUND)
message(FATAL_ERROR "OpenMP not found")
endif()
# Add yaml-cpp subdirectory before finding the package
add_subdirectory(external/yaml-cpp)
# # Find yaml-cpp
# find_package(yaml-cpp REQUIRED)
# Add include directories
include_directories(include)
# Set compiler flags based on build type
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -march=native -mtune=native")
# add a message to say that the build type is release
message(STATUS "Build type: Release")
elseif(CMAKE_BUILD_TYPE STREQUAL "Dev")
set(CMAKE_CXX_FLAGS_DEV "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wswitch-enum")
# add a message to say that the build type is dev
message(STATUS "Build type: Dev")
elseif(CMAKE_BUILD_TYPE STREQUAL "perf")
set(CMAKE_CXX_FLAGS_PERF "${CMAKE_CXX_FLAGS} -O2 -g -pg -fno-inline -fsanitize=address -fstack-protector -DPROFILE")
# add a message to say that the build type is perf
message(STATUS "Build type: perf")
endif()
# subdirectories
add_subdirectory(src)
add_subdirectory(tests)