-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
35 lines (28 loc) · 1.22 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
cmake_minimum_required(VERSION 3.10)
project(fig_gen LANGUAGES Fortran)
enable_language(Fortran)
option(USE_MPI "Build Parallel Version of Figuregen" OFF)
option(USE_NETCDF "Build with NetCDF" OFF)
option(GMT_PRE_5 "Version of GMT is older than 5.0" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
add_executable(figuregen FigureGen.F90)
if (${USE_MPI})
find_package(MPI REQUIRED Fortran)
set(CMAKE_Fortran_COMPILER "${MPI_Fortran_COMPILER}")
target_include_directories(figuregen PUBLIC SYSTEM ${MPI_Fortran_INCLUDE_PATH})
target_link_libraries(figuregen PUBLIC ${MPI_Fortran_LIBRARIES})
target_compile_definitions(figuregen PUBLIC CMPI)
endif ()
if (${USE_NETCDF})
set(NETCDF_F90 "YES")
find_package(NetCDF REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS Fortran)
target_include_directories(figuregen PUBLIC SYSTEM ${NETCDF_INCLUDES} ${HDF5_INCLUDE_DIRS})
target_link_libraries(figuregen PUBLIC ${NETCDF_LIBRARIES} ${HDF5_LIBRARIES})
target_compile_definitions(figuregen PUBLIC NETCDF)
endif ()
target_compile_definitions(figuregen PUBLIC VARFILLVAL)
set(CMAKE_Fortran_FLAGS "-Wall -Wextra -O3")
if (${GMT_PRE_5})
target_compile_definitions(figuregen PUBLIC GMTPRE5)
endif()