-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
60 lines (50 loc) · 1.82 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
cmake_minimum_required(VERSION 3.9..3.22)
project(decx VERSION 0.21.0 LANGUAGES C CXX Fortran)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Check C++/Fortran compatibility according to:
# https://enccs.github.io/cmake-workshop/cxx-fortran/
include(FortranCInterface)
fortrancinterface_verify(CXX)
# Some warnings have turned into a hard error since gfortran > 10.
# Ignore and compile anyway (https://forum.abinit.org/viewtopic.php?f=2&t=5205).
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
# Dependencies.
find_package(GSL REQUIRED)
find_package(Boost 1.59.0 REQUIRED)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
# Optimize release build.
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# Inter-procedural optimization.
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(IPO_SUPPORTED)
message(STATUS "IPO / LTO supported..")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "IPO / LTO enabled for all targets.")
else()
message(STATUS "IPO / LTO not supported: <${IPO_ERROR}>")
endif()
# Optimize for local architecture.
set(flag "-march=native")
foreach(LG IN ITEMS C CXX Fortran)
string(TOLOWER ${LG} lg)
include(Check${LG}CompilerFlag)
cmake_language(
CALL check_${lg}_compiler_flag
${flag} ${LG}_MARCH_NATIVE_SUPPORTED
)
if(${LG}_MARCH_NATIVE_SUPPORTED)
string(APPEND CMAKE_${LG}_FLAGS_RELEASE " ${flag}")
message(STATUS "${LG}: ${flag} enabled for all targets.")
endif()
endforeach()
# -O3 and -DNDebug are automatically passed in release mode.
endif()
# External source code dependencies.
add_subdirectory(extern)
# Main application.
add_subdirectory(src)