-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
73 lines (57 loc) · 2.55 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
cmake_minimum_required(VERSION 3.20.2)
project(Petaca Fortran C)
set(CMAKE_MODULE_PATH "${Petaca_SOURCE_DIR}/cmake/")
# If necessary, set YAJL_ROOT to the yajl installation root
find_package(YAJL REQUIRED)
if(YAJL_VERSION VERSION_LESS "2.0.1")
message(FATAL_ERROR "libyajl 2.0.1 or later is required")
endif()
# CMake build options
option(BUILD_EXAMPLES "Build example programs" OFF)
option(BUILD_HTML "Build HTML documentation (requires Sphinx)" OFF)
option(BUILD_SHARED_LIBS "Build shared object library" ON)
option(ENABLE_STD_MOD_PROC_NAME "Build with -assume std_mod_proc_name when using Intel" OFF)
include(CTest) # defines option BUILD_TESTING (on)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
endif()
# Set missing CMake defaults for the NAG Fortran compiler
if(CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
set(CMAKE_Fortran_FLAGS_DEBUG "-u -O0 -gline -C -nan")
set(CMAKE_Fortran_FLAGS_RELEASE "-u -O3")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g")
endif()
set(Petaca_INCLUDE_DIR ${Petaca_SOURCE_DIR}/include)
# Disable assertions in release builds
add_compile_definitions($<$<CONFIG:Release,RelWithDebInfo>:NDEBUG>)
# Compiler bug workarounds
add_compile_definitions(
$<$<COMPILE_LANG_AND_ID:Fortran,Intel>:INTEL_BUG20231123>
$<$<COMPILE_LANG_AND_ID:Fortran,IntelLLVM>:INTEL_BUG20231122>
$<$<COMPILE_LANG_AND_ID:Fortran,IntelLLVM>:INTEL_BUG20231123>
$<$<COMPILE_LANG_AND_ID:Fortran,Intel,IntelLLVM>:INTEL_BUG20231205>
$<$<COMPILE_LANG_AND_ID:Fortran,Intel,IntelLLVM>:INTEL_BUG20231210>
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:GNU_PR93762>
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:GNU_PR112964>
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:GNU_PR114827>
$<$<COMPILE_LANG_AND_ID:Fortran,NAG>:NAG_BUG20231204>
$<$<COMPILE_LANG_AND_ID:Fortran,NAG>:NAG_BUG20231206>
)
# Required compiler options
add_compile_options($<$<COMPILE_LANG_AND_ID:Fortran,NAG>:-f2018>)
add_compile_options($<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-ffree-line-length-none>)
add_compile_options("$<$<COMPILE_LANG_AND_ID:Fortran,Intel,IntelLLVM>:-standard-semantics>"
"$<$<AND:$<NOT:$<BOOL:${ENABLE_STD_MOD_PROC_NAME}>>,$<COMPILE_LANG_AND_ID:Fortran,Intel,IntelLLVM>>:SHELL:-assume nostd_mod_proc_name>")
add_subdirectory(src)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_HTML)
find_package(Sphinx REQUIRED)
add_subdirectory(doc/sphinx)
endif()
add_subdirectory(templates)