-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeLists.txt
102 lines (80 loc) · 2.72 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
########################################################################
# Preamble
########################################################################
cmake_minimum_required( VERSION 3.14 )
project( njoy21 LANGUAGES CXX )
enable_language( Fortran )
########################################################################
# Project-wide setup
########################################################################
find_package( Python3 3.5 REQUIRED )
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED YES )
option( njoy21_unit_tests
"Compile the njoy21 unit tests and integrate with ctest" ON
)
option( strict_compile
"Treat all warnings as errors." ON
)
# Compile flags
set( common_flags "-Wall" "-Wextra" "-Wpedantic" )
set( strict_flags "-Werror" "-Wno-unknown-warning-option" )
set( release_flags "-O3" )
set( debug_flags "-O0" "-g" )
########################################################################
# Dependencies
########################################################################
set( REPOSITORIES "release"
CACHE STRING
"Options for where to fetch repositories: develop, release, local"
)
if( REPOSITORIES STREQUAL "develop" )
include( cmake/develop_dependencies.cmake )
elseif( REPOSITORIES STREQUAL "release" )
include( cmake/release_dependencies.cmake )
elseif( REPOSITORIES STREQUAL "local" )
include( cmake/local_dependencies.cmake )
endif()
########################################################################
# Project targets
########################################################################
add_library( njoy21_library INTERFACE
)
target_include_directories( njoy21_library
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/src/
src/
)
target_link_libraries( njoy21_library
INTERFACE ENDFtk
INTERFACE dimwits
INTERFACE lipservice
INTERFACE njoy_c_bindings
INTERFACE tclap-adapter
INTERFACE utility
INTERFACE catch-adapter
)
#######################################################################
# Top-level Only
#######################################################################
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
add_executable( njoy21
src/main.cpp
)
target_link_libraries( njoy21
PUBLIC njoy21_library
)
target_compile_options( njoy21 PRIVATE
${common_flags}
$<$<BOOL:${strict_compile}>:${strict_flags}>
$<$<CONFIG:DEBUG>:${debug_flags}>
$<$<CONFIG:RELEASE>:${release_flags}>
)
# unit testing
if( njoy21_unit_tests )
include( cmake/unit_testing.cmake )
endif()
# integral testing
message( STATUS "Adding integral testing" )
enable_testing()
add_subdirectory( tests )
endif()