forked from mhm-ufz/mHM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (62 loc) · 2.02 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
# mHM cmake script
cmake_minimum_required(VERSION 3.14)
# get version and date from files (version.txt and version_date.txt)
include(cmake/version.cmake)
get_version(MHM_VER MHM_VER_DEV MHM_DATE)
# create the project
project(mhm
VERSION ${MHM_VER}
DESCRIPTION "The mesoscale Hydrological Model"
HOMEPAGE_URL "https://www.ufz.de/mhm"
LANGUAGES Fortran
)
option(BUILD_MHM_DRIVER "Build mHM with executable driver." ON)
option(BUILD_MHM_PYBIND "Build mHM python bindings." OFF)
if(BUILD_MHM_PYBIND)
set(BUILD_MHM_LIB_SHARED ON)
endif()
add_subdirectory(src)
if(BUILD_MHM_DRIVER)
add_executable(mhm src/mHM/mhm_driver.f90)
target_link_libraries(mhm PRIVATE mhm_lib)
# add install option
if(NOT BUILD_MHM_PYBIND)
install(TARGETS mhm DESTINATION bin)
endif()
endif()
if(BUILD_MHM_PYBIND)
add_subdirectory(pybind/src)
endif()
# add full version and date to pre-processor flags (qoutes need in before hand)
target_compile_definitions(mhm_lib PRIVATE
MHMVERSION='${MHM_VER_DEV}'
MHMDATE='${MHM_DATE}'
)
# setup coverage with GNU
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND CMAKE_WITH_COVERAGE AND EXISTS "CI-scripts")
message(STATUS "mHM: add coverage")
include(cmake/CodeCoverage.cmake)
append_coverage_compiler_flags_to_target(mhm_lib)
append_coverage_compiler_flags_to_target(mhm)
SETUP_TARGET_FOR_COVERAGE_LCOV(
NAME mhm_coverage_CI
EXECUTABLE ../CI-scripts/run_cmake_coverage.sh
DEPENDENCIES mhm mhm_lib
GENHTML_ARGS -t "mHM coverage" --html-prolog ../doc/html_files/cov_header.prolog
)
endif()
# automatically enable testing (OFF by default)
option(BUILD_TESTING "Build with pfUnit tests." OFF)
include(CTest)
# add pfunit test folder
if(BUILD_TESTING AND EXISTS "src/tests")
add_subdirectory(src/tests)
endif()
# With this, paths are added to the INSTALL_RPATH, and via the second command also to the build.
if (CMAKE_BUILD_MODULE_SYSTEM_INDEPENDENT)
set_target_properties(mhm
PROPERTIES
INSTALL_RPATH "${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}"
BUILD_WITH_INSTALL_RPATH ON
)
endif()