-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
278 lines (262 loc) · 8.79 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# SPDX-FileCopyrightText: 2020 W. Traylor <wolfgang.traylor@senckenberg.de>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
cmake_minimum_required (VERSION 3.10)
# Update README.md if you increase required CMake version.
project ("Modular Megafauna Model"
# This version must match exactly the Git tag!
# Compare the "check_version" job in ".gitlab-ci.yml".
VERSION 1.1.6
DESCRIPTION "A physiological, dynamic herbivore simulator in C++."
LANGUAGES CXX
)
set (SOURCE_FILES
external/cpptoml/include/cpptoml.h
include/Fauna/Output/habitat_data.h
include/Fauna/average.h
include/Fauna/date.h
include/Fauna/environment.h
include/Fauna/forage_types.h
include/Fauna/forage_values.h
include/Fauna/grass_forage.h
include/Fauna/habitat.h
include/Fauna/habitat_forage.h
include/Fauna/world.h
src/Fauna/Output/aggregator.cpp
src/Fauna/Output/aggregator.h
src/Fauna/Output/combined_data.cpp
src/Fauna/Output/combined_data.h
src/Fauna/Output/habitat_data.cpp
src/Fauna/Output/herbivore_data.cpp
src/Fauna/Output/herbivore_data.h
src/Fauna/Output/text_table_writer.cpp
src/Fauna/Output/text_table_writer.h
src/Fauna/Output/text_table_writer_options.h
src/Fauna/Output/writer_interface.h
src/Fauna/average.cpp
src/Fauna/breeding_season.cpp
src/Fauna/breeding_season.h
src/Fauna/cohort_population.cpp
src/Fauna/cohort_population.h
src/Fauna/create_herbivore_cohort.cpp
src/Fauna/create_herbivore_cohort.h
src/Fauna/create_herbivore_common.cpp
src/Fauna/create_herbivore_common.h
src/Fauna/date.cpp
src/Fauna/date_interval.cpp
src/Fauna/date_interval.h
src/Fauna/expenditure_components.cpp
src/Fauna/expenditure_components.h
src/Fauna/fatmass_energy_budget.cpp
src/Fauna/fatmass_energy_budget.h
src/Fauna/feed_herbivores.cpp
src/Fauna/feed_herbivores.h
src/Fauna/fileystem.cpp
src/Fauna/fileystem.h
src/Fauna/forage_base.cpp
src/Fauna/forage_distribution_algorithms.cpp
src/Fauna/forage_distribution_algorithms.h
src/Fauna/forage_types.cpp
src/Fauna/forage_values.cpp
src/Fauna/foraging_limits.cpp
src/Fauna/foraging_limits.h
src/Fauna/get_forage_demands.cpp
src/Fauna/get_forage_demands.h
src/Fauna/grass_forage.cpp
src/Fauna/habitat.cpp
src/Fauna/habitat_forage.cpp
src/Fauna/herbivore_base.cpp
src/Fauna/herbivore_base.h
src/Fauna/herbivore_cohort.cpp
src/Fauna/herbivore_cohort.h
src/Fauna/herbivore_interface.h
src/Fauna/herbivore_vector.h
src/Fauna/hft.cpp
src/Fauna/hft.h
src/Fauna/insfile_reader.cpp
src/Fauna/insfile_reader.h
src/Fauna/mortality_factors.cpp
src/Fauna/mortality_factors.h
src/Fauna/net_energy_models.cpp
src/Fauna/net_energy_models.h
src/Fauna/parameters.cpp
src/Fauna/parameters.h
src/Fauna/population_interface.cpp
src/Fauna/population_interface.h
src/Fauna/population_list.h
src/Fauna/reproduction_models.cpp
src/Fauna/reproduction_models.h
src/Fauna/simulate_day.cpp
src/Fauna/simulate_day.h
src/Fauna/simulation_unit.cpp
src/Fauna/simulation_unit.h
src/Fauna/world.cpp
src/Fauna/world_constructor.cpp
src/Fauna/world_constructor.h
)
add_library (ModularMegafaunaModel STATIC ${SOURCE_FILES})
# This library uses C++11 features, but does not require it from programs that
# use this library.
target_compile_features (ModularMegafaunaModel PRIVATE cxx_std_11)
target_include_directories (ModularMegafaunaModel
PUBLIC
include/
PRIVATE
external/cpptoml/include/
include/Fauna/
include/Fauna/Output/
src/Fauna/
src/Fauna/Output/
)
###########################################################################
########################## UNIT TESTS ###################################
###########################################################################
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/CMake-codecov"
${CMAKE_MODULE_PATH})
if (BUILD_TESTING)
add_executable (megafauna_unit_tests
${SOURCE_FILES}
src/Fauna/Output/aggregator.test.cpp
src/Fauna/Output/combined_data.test.cpp
src/Fauna/Output/datapoint.h
src/Fauna/Output/habitat_data.test.cpp
src/Fauna/Output/herbivore_data.test.cpp
src/Fauna/Output/text_table_writer.test.cpp
src/Fauna/average.test.cpp
src/Fauna/breeding_season.test.cpp
src/Fauna/cohort_population.test.cpp
src/Fauna/date.test.cpp
src/Fauna/date_interval.test.cpp
src/Fauna/expenditure_components.test.cpp
src/Fauna/fatmass_energy_budget.test.cpp
src/Fauna/feed_herbivores.test.cpp
src/Fauna/fileystem.test.cpp
src/Fauna/forage_distribution_algorithms.test.cpp
src/Fauna/forage_values.test.cpp
src/Fauna/foraging_limits.test.cpp
src/Fauna/get_forage_demands.test.cpp
src/Fauna/grass_forage.test.cpp
src/Fauna/habitat.test.cpp
src/Fauna/habitat_forage.test.cpp
src/Fauna/herbivore_base.test.cpp
src/Fauna/herbivore_cohort.test.cpp
src/Fauna/hft.test.cpp
src/Fauna/insfile_reader.test.cpp
src/Fauna/mortality_factors.test.cpp
src/Fauna/net_energy_models.test.cpp
src/Fauna/parameters.test.cpp
src/Fauna/reproduction_models.test.cpp
src/Fauna/world.test.cpp
src/Fauna/world_constructor.test.cpp
tests/catch.hpp
tests/catch_main.cpp
tests/dummy_habitat.h
tests/dummy_herbivore.h
tests/dummy_herbivore.test.cpp
tests/dummy_herbivore_base.h
tests/dummy_hft.h
tests/dummy_population.h
tests/dummy_population.test.cpp
tools/demo_simulator/logistic_grass.cpp
tools/demo_simulator/logistic_grass.h
tools/demo_simulator/logistic_grass.test.cpp
tools/demo_simulator/simple_habitat.cpp
tools/demo_simulator/simple_habitat.h
tools/demo_simulator/simple_habitat.test.cpp
)
target_compile_features (megafauna_unit_tests PRIVATE cxx_std_11)
target_include_directories (megafauna_unit_tests
PRIVATE
external/cpptoml/include/
include/
include/Fauna/
include/Fauna/Output/
src/Fauna/
src/Fauna/Output/
tests/
)
# We need to check that the example TOML file is read correctly.
configure_file (
"examples/megafauna.toml"
"${CMAKE_CURRENT_BINARY_DIR}/megafauna.toml"
COPYONLY
)
# Code coverage for codecov.io
# Compare <https://github.com/RWTH-HPC/CMake-codecov>
if(ENABLE_COVERAGE)
find_package(codecov)
add_coverage(megafauna_unit_tests)
coverage_evaluate()
# Exclude "external/" folder from coverage
list(APPEND LCOV_REMOVE_PATTERNS
"'${PROJECT_SOURCE_DIR}/external/*'"
"'${PROJECT_SOURCE_DIR}/tests/catch.hpp'"
)
endif(ENABLE_COVERAGE)
endif(BUILD_TESTING)
###########################################################################
################### INSTRUCTION FILE LINTER #############################
###########################################################################
add_executable (megafauna_insfile_linter
tools/insfile-linter/linter.cpp
)
target_compile_features (megafauna_insfile_linter PRIVATE cxx_std_11)
target_link_libraries (megafauna_insfile_linter
ModularMegafaunaModel
)
###########################################################################
######################## DEMO SIMULATOR #################################
###########################################################################
option (BUILD_DEMO_SIMULATOR
"Whether to build the simple megafauna demo simulator."
ON
)
if(BUILD_DEMO_SIMULATOR)
add_executable (megafauna_demo_simulator
tools/demo_simulator/demo_simulator.cpp
tools/demo_simulator/demo_simulator.h
tools/demo_simulator/logistic_grass.cpp
tools/demo_simulator/logistic_grass.h
tools/demo_simulator/simple_habitat.cpp
tools/demo_simulator/simple_habitat.h
)
target_include_directories (megafauna_demo_simulator
PRIVATE
external/cpptoml/include/
)
target_compile_features (megafauna_demo_simulator PRIVATE cxx_std_11)
target_link_libraries (megafauna_demo_simulator
ModularMegafaunaModel
)
configure_file (
"tools/demo_simulator/demo_results.Rmd"
"${CMAKE_CURRENT_BINARY_DIR}/demo_results.Rmd"
COPYONLY
)
configure_file (
"examples/demo_simulation.toml"
"${CMAKE_CURRENT_BINARY_DIR}/demo_simulation.toml"
COPYONLY
)
configure_file (
"examples/megafauna.toml"
"${CMAKE_CURRENT_BINARY_DIR}/megafauna.toml"
COPYONLY
)
file(
COPY "tools/demo_simulator/run_demo"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}"
FILE_PERMISSIONS
WORLD_READ GROUP_READ OWNER_READ
WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE
OWNER_WRITE
)
endif()
###########################################################################
#################### DOXYGEN DOCUMENTATION ##############################
###########################################################################
option (BUILD_DOC "Build doxygen documentaton" OFF)
option (STOP_DOXYGEN_ON_WARNING "Let building of documentation fail on warning (for CI)" OFF)
if (BUILD_DOC)
add_subdirectory (docs/)
endif()