-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·63 lines (51 loc) · 1.78 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
cmake_minimum_required(VERSION 3.9.0)
set(PROJECT_NAME textopt)
project(${PROJECT_NAME})
set(VERSION_MAJOR "0")
set(VERSION_MINOR "1")
set(VERSION_PATCH "2")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
enable_language(CXX)
enable_language(Fortran)
set(CMAKE_CXX_STANDARD 17)
set(NO_OPENMP OFF CACHE BOOL "Compile without OpenMP support")
set(BUILD_NATIVE ON CACHE BOOL "Compile using the architecture currently in use")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
if(BUILD_NATIVE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Og")
endif()
find_package(SFML COMPONENTS system window graphics REQUIRED)
find_package(Eigen3 REQUIRED NO_MODULE)
find_package(YAML-CPP REQUIRED)
if(NOT NO_OPENMP)
find_package(OpenMP)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif()
# Enable link time optimization if supported
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=auto")
endif()
else()
message(WARNING "IPO/LTO is not supported: ${output}")
endif()
include_directories(
${PROJECT_SOURCE_DIR}/include
SYSTEM
${Eigen3_INCLUDE_DIR}
${SFML_INCLUDE_DIR}
${YAML_CPP_INCLUDE_DIR}
)
add_subdirectory(src)