forked from nextsimhub/nextsimdg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
100 lines (79 loc) · 3.04 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.12)
set(CMAKE_CXX_STANDARD 17)
project(nextsim_dg)
find_package(PkgConfig)
pkg_search_module(NETCDF_CXX4 netcdf-cxx4)
if (NETCDF_CXX4_FOUND)
set(NSDG_NetCDF_Library "${NETCDF_CXX4_LIBRARIES}")
set(netCDF_INCLUDE_DIR "${NETCDF_CXX4_INCLUDE_DIRS}")
set(netCDF_LIB_DIR "${NETCDF_CXX4_LIBRARY_DIRS}")
else()
find_package(netCDF REQUIRED)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
set(NSDG_NetCDF_Library "netcdf-cxx4")
else()
set(NSDG_NetCDF_Library "netcdf_c++4")
endif()
endif()
OPTION(WITH_THREADS "Build with support for openmp" OFF)
find_package(OpenMP)
if (OPENMP_FOUND)
IF(WITH_THREADS)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
# Regarding Boost.Log, if our application consists of more
# than one modules that use it, we must link to the shared
# version. If we have a single executable or a single module
# that works, we may use the static version.
# By default, it is assumed that the library is built in
# static mode. Use the following definition to indicate that
# the code will be linked against dynamically loaded boost
# libraries.
add_definitions(-DBOOST_ALL_DYN_LINK)
find_package(Boost COMPONENTS program_options log REQUIRED)
# Add the doctest header library
set(DOCTEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
add_library(doctest::doctest IMPORTED INTERFACE)
set_property(TARGET doctest::doctest PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${DOCTEST_INCLUDE_DIR}")
find_package(Eigen3 3.4 REQUIRED)
# To add netCDF to a target:
# target_include_directories(target PUBLIC ${netCDF_INCLUDE_DIR})
# target_link_directories(target PUBLIC ${netCDF_LIB_DIR})
# target_link_libraries(target LINK_PUBLIC "${NSDG_NetCDF_Library}")
# Set the list of components that define modules. Component subdirectories are
# contained in this directory level and contain src/modules/ and
# src/modules/include/ subdirectories
#set(ModularComponents
#"physics"
#)
# Set the components which provide source or object code to the main model
set(CodeComponents
"physics"
"dynamics"
)
# The exact selection of dimensions and Types available to ModelArray
if(True)
set(ModelArrayStructure "discontinuousgalerkin")
endif()
# Set an empty list of sources
set(NextsimSources "")
# Set an empty list of include directories
set(NextsimIncludeDirs "")
# Build the core model. Defines the 'parse_modules' target
add_subdirectory(core)
# Build all components
foreach(compo ${CodeComponents})
add_subdirectory("${compo}")
endforeach()
# Link the model
add_executable(nextsim "${NextsimSources}")
target_include_directories(nextsim PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${NextsimIncludeDirs}"
"${netCDF_INCLUDE_DIR}"
)
target_link_directories(nextsim PUBLIC "${netCDF_LIB_DIR}")
target_link_libraries(nextsim LINK_PUBLIC Boost::program_options Boost::log "${NSDG_NetCDF_Library}" Eigen3::Eigen)