-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
164 lines (139 loc) · 5.35 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent
# The CMake config files were created based on the public template at
# https://github.com/LecrisUT/CMake-Template
#[=================================================================================================[
# Basic project definition #
]=================================================================================================]
cmake_minimum_required(VERSION 3.22...3.31)
list(APPEND CMAKE_MESSAGE_CONTEXT Fortuno)
project(
Fortuno
VERSION 0.1.0
DESCRIPTION "Flextensible unit testing framework for Fortran"
HOMEPAGE_URL "https://github.com/fortuno-repos/fortuno"
LANGUAGES Fortran
)
#[=================================================================================================[
# Build configuration options #
]=================================================================================================]
include(config.cmake)
#[=================================================================================================[
# Project configuration #
]=================================================================================================]
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(FortunoHelpers)
if (FORTUNO_INSTALL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
endif ()
find_program(FYPP fypp)
set(BUILD_SHARED_LIBS ${FORTUNO_BUILD_SHARED_LIBS})
fortuno_setup_build_type("RelWithDebInfo")
if (FORTUNO_WITH_MPI)
find_package(MPI REQUIRED)
if(NOT MPI_FORTRAN_FOUND)
message(FATAL_ERROR "Failed to detect MPI-framework for Fortran")
endif()
endif ()
#[=================================================================================================[
# Build definitions #
]=================================================================================================]
add_subdirectory(include)
add_subdirectory(src)
if (FORTUNO_WITH_EXAMPLES)
add_subdirectory(example)
endif ()
if (FORTUNO_WITH_TESTS)
enable_testing()
add_subdirectory(test)
endif ()
#[=================================================================================================[
# Install or Export #
]=================================================================================================]
if (FORTUNO_INSTALL)
# pkg-config files
configure_file(cmake/fortuno.pc.in fortuno.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT Fortuno_development
)
if (FORTUNO_WITH_SERIAL)
configure_file(cmake/fortuno_serial.pc.in fortuno_serial.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno_serial.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT Fortuno_development
)
endif ()
if (FORTUNO_WITH_MPI)
configure_file(cmake/fortuno_mpi.pc.in fortuno_mpi.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno_mpi.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT Fortuno_development
)
endif ()
if (FORTUNO_WITH_COARRAY)
configure_file(cmake/fortuno_coarray.pc.in fortuno_coarray.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/fortuno_coarray.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT Fortuno_development
)
endif ()
# cmake export files
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfigVersion.cmake
VERSION ${PROJECT_VERSION}
# TODO: Switch to SameMajorVersion as soon as project version reaches 1.0.
COMPATIBILITY SameMinorVersion
)
configure_package_config_file(
cmake/FortunoConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/FortunoConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno
COMPONENT Fortuno_development
)
export(
EXPORT FortunoTargets
FILE FortunoTargets.cmake
NAMESPACE Fortuno::
)
install(
EXPORT FortunoTargets
FILE FortunoTargets.cmake
NAMESPACE Fortuno::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno
COMPONENT Fortuno_development
)
endif ()
# Make project available for FetchContent
if (NOT PROJECT_IS_TOP_LEVEL)
# Propagate variables
if (CMAKE_VERSION VERSION_LESS 3.25)
# TODO: Remove when required minimum cmake version is >= 3.25
set(Fortuno_VERSION ${Fortuno_VERSION} PARENT_SCOPE)
set(Fortuno_VERSION_MAJOR ${Fortuno_VERSION_MAJOR} PARENT_SCOPE)
set(Fortuno_VERSION_MINOR ${Fortuno_VERSION_MINOR} PARENT_SCOPE)
set(Fortuno_VERSION_PATCH ${Fortuno_VERSION_PATCH} PARENT_SCOPE)
set(Fortuno_VERSION_TWEAK ${Fortuno_VERSION_TWEAK} PARENT_SCOPE)
else ()
return(
PROPAGATE
Fortuno_VERSION
Fortuno_VERSION_MAJOR
Fortuno_VERSION_MINOR
Fortuno_VERSION_PATCH
Fortuno_VERSION_TWEAK
)
endif ()
endif ()