-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
96 lines (78 loc) · 3.37 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
cmake_minimum_required(VERSION 3.16)
message(STATUS "(EC) Generating vgrid Makefile")
#----- Append EC specific module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_rpn/modules $ENV{EC_CMAKE_MODULE_PATH})
include(ec_init) # Initialise compilers and ec specific functions
ec_git_version() # Get version from git state
ec_parse_manifest() # Parse MANIFEST file
project(${NAME} DESCRIPTION "${DESCRIPTION}" LANGUAGES C Fortran)
set(PROJECT_VERSION ${VERSION}${STATE})
set(vgrid_VERSION ${PROJECT_VERSION} CACHE INTERNAL "vgrid version" FORCE) # Needed for cascaded version identification
message(STATUS "(EC) ${PROJECT_NAME} version = ${PROJECT_VERSION}")
ec_build_info() # Generate build information
if (EC_INIT_DONE LESS 2)
include(CTest)
add_custom_target(check COMMAND CTEST_OUTPUT_ON_FAILURE=true ${CMAKE_CTEST_COMMAND})
endif()
include(ec_doxygen) # Doxygen target (-DWITH_DOC=TRUE)
include(ec_compiler_presets)
include(ec_openmp) # Enable OpenMP (-DWITH_OPENMP=TRUE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1")
# Needed since ubuntu 20.04
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed -ldl")
if (NOT rmn_FOUND)
find_package(rmn ${rmn_REQ_VERSION} REQUIRED)
endif()
if (NOT tdpack_FOUND)
find_package(tdpack ${tdpack_REQ_VERSION})
endif()
link_libraries("-Wl,--disable-new-dtags")
set(VGRID_BUILD_SHARED ON)
if (${RMN_LLVM_ADDRESS_SANITIZER})
set(VGRID_BUILD_SHARED OFF)
endif()
add_subdirectory(src/lib lib)
add_subdirectory(src/utils utils)
#add_subdirectory(src/examples examples)
add_subdirectory(test test)
#----- Generate the config file for the project to be usable via cmake's find_package command
set(INCLUDE_INSTALL_DIR include)
set(LIB_INSTALL_DIR lib)
set(CONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}")
if (${VGRID_BUILD_SHARED})
install(EXPORT ${PROJECT_NAME}-shared-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CONFIG_INSTALL_DIR})
endif()
install(EXPORT ${PROJECT_NAME}-static-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CONFIG_INSTALL_DIR})
include(CMakePackageConfigHelpers)
configure_package_config_file(
"Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CONFIG_INSTALL_DIR}"
)
#----- Packaging
ec_package_name() # Define package prefix
ec_build_config() # Create build configuration script
ec_prepare_ssm() # Prepare ssm packaging files
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_VENDOR "ECCC")
set(CPACK_PACKAGE_CONTACT "${MAINTAINER}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/package")
set(CPACK_PACKAGE/_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${NAME}_${PROJECT_VERSION}")
include(CPack)