-
Notifications
You must be signed in to change notification settings - Fork 55
/
CMakeLists.txt
91 lines (70 loc) · 2.48 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
cmake_minimum_required(VERSION 3.10)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.321.tar.gz"
SHA1 "5e53cbb0429037ea8e2592bfd92704b8ff3ab492"
LOCAL
)
project(NPDECODES)
message("Project source dir =" "${PROJECT_SOURCE_DIR}")
message("Project binary dir =" "${PROJECT_BINARY_DIR}")
# Check that this is not an in-source build:
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif()
#setup compiler
set(CMAKE_CXX_STANDARD 17)
#enable warnings
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-Wall COMPILER_SUPPORTS_WALL)
CHECK_CXX_COMPILER_FLAG(-Wextra COMPILER_SUPPORTS_WEXTRA)
CHECK_CXX_COMPILER_FLAG(-Wconversion COMPILER_SUPPORTS_WCONVERSION)
add_library(warning_flags INTERFACE)
if(COMPILER_SUPPORTS_WALL)
target_compile_options(warning_flags INTERFACE -Wall)
endif()
if(COMPILER_SUPPORTS_WEXTRA)
target_compile_options(warning_flags INTERFACE -Wextra)
endif()
if(COMPILER_SUPPORTS_WCONVERSION)
target_compile_options(warning_flags INTERFACE -Wconversion)
endif()
# Add switches
###############################################################################
option(HOMEWORKS "usage: cmake -DHOMEWORKS=ON/OFF .." ON)
message(STATUS "HOMEWORKS ${HOMEWORKS}")
option(DEVELOPERS "usage: cmake -DDEVELOPERS=ON/OFF .." ON)
message(STATUS "DEVELOPERS ${DEVELOPERS}")
option(LECTURECODES "usage: cmake -DLECTURECODES=ON/OFF .." ON)
message(STATUS "LECTURECODES ${LECTURECODES}")
option(MASTERSOLUTION "usage: cmake -DMASTERSOLUTION=ON/OFF .." ON)
message(STATUS "MASTERSOLUTION ${MASTERSOLUTION}")
option(MYSOLUTION "usage: cmake -DMYSOLUTION=ON/OFF .." ON)
message(STATUS "MYSOLUTION ${MYSOLUTION}")
# Get Dependencies
# (don't forget to update cmake/Config.cmake.in !
###############################################################################
# Get Eigen
hunter_add_package(Eigen)
find_package(Eigen3 CONFIG REQUIRED)
# Get LehrFEMpp
hunter_add_package(lehrfempp)
find_package(lehrfempp CONFIG REQUIRED)
# Get Google Test
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
# Get some boost program options if LectureCodes are enabled:
if(LECTURECODES)
hunter_add_package(Boost COMPONENTS program_options)
find_package(Boost CONFIG REQUIRED program_options)
endif()
# Add subdirectories
if(HOMEWORKS)
add_subdirectory(homeworks)
endif()
if(DEVELOPERS)
add_subdirectory(developers)
endif()
if(LECTURECODES)
add_subdirectory(lecturecodes)
endif()