forked from esmf-org/esmf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (47 loc) · 1.89 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
cmake_minimum_required(VERSION 3.22)
# Where to look for the local Find<Package>.cmake files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Driver/cmake")
# Find ESMF
find_package(ESMF 8.6.0 MODULE REQUIRED)
# Set compilers consistent with ESMF
set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}")
set(CMAKE_CXX_COMPILER "${ESMF_CXXCOMPILER}")
set(CMAKE_C_COMPILER "${ESMF_CCOMPILER}")
# Project
project(ESMX
VERSION 1.0.0
LANGUAGES Fortran CXX C
)
# Add ESMX driver
add_subdirectory(Driver)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -fbacktrace -O0 -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0 -check all -fpe0 -ftrapuv -init=snan,arrays")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fast")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2 -fast")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0")
else()
message(WARNING "${CMAKE_Fortran_COMPILER_ID} Fortran compiler will be used with default options")
endif()
# define ESMX_EXE_NAME
if(NOT DEFINED ESMX_EXE_NAME)
set(ESMX_EXE_NAME "esmx_app")
endif()
# Create ESMX executable
add_executable(${ESMX_EXE_NAME} ESMX_App.F90)
target_include_directories(${ESMX_EXE_NAME} PUBLIC ${PROJECT_BINARY_DIR})
target_link_libraries(${ESMX_EXE_NAME} PUBLIC esmx_driver)
set_target_properties(${ESMX_EXE_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
# Install executable
install(
TARGETS ${ESMX_EXE_NAME}
EXPORT esmx
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)