forked from chengcli/canoe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
100 lines (83 loc) · 3.2 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
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(canoe
LANGUAGES CXX C Fortran
)
message(STATUS "")
message(STATUS "== Setting up canoe library ==")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Default Build Type = Release")
message(STATUS "")
else()
message(STATUS "Build Type = ${CMAKE_BUILD_TYPE}")
message(STATUS "")
endif()
# load all modules
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/)
# load all macros
FILE(GLOB _macro_files "${CMAKE_SOURCE_DIR}/cmake/macros/*.cmake")
FOREACH(_file ${_macro_files})
MESSAGE(STATUS "Include ${_file}")
INCLUDE(${_file})
ENDFOREACH()
## 1. set up compiler flags ##
message(STATUS "1. Set up project compiler flags ...")
message(STATUS "Include ${CMAKE_SOURCE_DIR}/cmake/compilers.cmake")
include(${CMAKE_SOURCE_DIR}/cmake/compilers.cmake)
## 2. set up project specific configuration ##
message(STATUS "2. Set up project parameters ...")
# load custom task
message(STATUS "Load custom task = ${TASK}")
if (NOT ${TASK} STREQUAL "")
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples/${TASK}.cmake)
message(STATUS "Load custom setting - ${TASK} -")
message(STATUS "Include ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples/${TASK}.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples/${TASK}.cmake)
else()
message(FATAL_ERROR "Cannot find custom file cmake/examples/${TASK}.cmake")
endif()
set(TASK ${TASK} CACHE STRING "Custom task to be performed")
else()
set(TASK "default" CACHE STRING "Custom task to be performed")
endif()
message(STATUS "Include ${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/parameters.cmake)
find_package(Eigen3 REQUIRED)
## 3. set up project system libraries ##
message(STATUS "3. Set up system libraries")
#message(STATUS "Include ${CMAKE_SOURCE_DIR}/cmake/athena.cmake")
#include(${CMAKE_SOURCE_DIR}/cmake/eigen.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/yamlpp.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/athena.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/application.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/rfm.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/disort.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/rrtmg.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pvfmm.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/minichem.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pybind11.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/gtest.cmake)
## 4. set up project configure file and library ##
message(STATUS "4. Set up project libraries")
configure_file(${CMAKE_SOURCE_DIR}/configure.hpp.in configure.hpp @ONLY)
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(data)
## 5. set up examples and tests
message(STATUS "6. Set up unit tests")
add_subdirectory(examples)
add_subdirectory(tests)
## 6. set up python binding ##
if (PYTHON_BINDINGS)
add_subdirectory(python)
endif()
## 7. add uninstall targets ##
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(canoe_uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)