Debian Codegraph @

cmake/tribits/core/package_arch/TribitsProjectImpl.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10
11 #
12 # This file is included from TribitsProject.cmake which has already set to the
13 # tribits implementation to use in {PROJECT_NAME}_TRIBITS_DIR.
14 #
15
16 set(CMAKE_MODULE_PATH
17 ${CMAKE_CURRENT_SOURCE_DIR}
18 ${CMAKE_CURRENT_SOURCE_DIR}/cmake
19 ${${PROJECT_NAME}_TRIBITS_DIR}/core/utils
20 ${${PROJECT_NAME}_TRIBITS_DIR}/core/common
21 ${${PROJECT_NAME}_TRIBITS_DIR}/core/test_support
22 ${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch
23 ${${PROJECT_NAME}_TRIBITS_DIR}/core/config_tests
24 ${${PROJECT_NAME}_TRIBITS_DIR}/core/modules
25 ${${PROJECT_NAME}_TRIBITS_DIR}/core/installation
26 )
27
28 if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
29 message("CMAKE_MODULE_PATH='${CMAKE_MODULE_PATH}'")
30 endif()
31
32 include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")
33 tribits_asesrt_minimum_cmake_version()
34 include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)
35
36 # TriBITS package_arch includes
37 include(TribitsIncludeDirectories)
38 include(TribitsFindPythonInterp)
39 include(TribitsGlobalMacros)
40 include(TribitsConfigureCTestCustom)
41 include(TribitsGenerateResourceSpecFile)
42 include(TribitsPackageDependencies)
43 include(TribitsPrintDependencyInfo)
44 include(TribitsPackagingSupport)
45 include(TribitsConfigureTiming)
46
47 # TriBITS utils includes
48 include(AdvancedSet)
49 include(AdvancedOption)
50 include(TimingUtils)
51 include(SetDefault)
52
53
54 #
55 # Defines a TriBITS project (the guts).
56 #
57
58 macro(tribits_project_impl)
59
60 #
61 # A) Basic top-level TriBITS project stuff
62 #
63
64 message("")
65 message("Configuring ${PROJECT_NAME} build directory")
66 message("")
67
68 # A.1) Set some basic system vars and info you can't change
69 tribits_assert_and_setup_project_and_static_system_vars()
70
71 # A.2) Read user provided options from specified files. It is important to
72 # process these files *very* early on so that they have the same basic
73 # effect of setting these variables directly in the cache.
74 tribits_read_in_options_from_file()
75
76 # A.3) Get some other basic system info that is useful early on in
77 # configuration
78 tribits_setup_basic_system_vars()
79 tribits_find_python_interp()
80 find_package(Git)
81 if (NOT "${GIT_VERSION_STRING_OVERRIDE}" STREQUAL "")
82 set(GIT_VERSION_STRING ${GIT_VERSION_STRING_OVERRIDE}) # For testing!
83 endif()
84
85 #
86 # A.4) Read in the Project's version file
87 #
88 # NOTE: The file Version.cmake must be read *before* the global options are
89 # read because the variables defined in Version.cmake provide defaults for
90 # many of these options.
91 #
92 tribits_project_read_version_file(${PROJECT_SOURCE_DIR})
93
94 # Since the version header file is now configured the root build
95 # dir needs to be on the include path
96 tribits_include_directories(${CMAKE_CURRENT_BINARY_DIR})
97
98 #
99 # B) Set up user options and global variables that will be used throughout
100 #
101
102 message("")
103 message("Setting up major user options ...")
104 message("")
105
106 tribits_define_global_options_and_define_extra_repos()
107
108 # Have to start timing after we read in the major options since that
109 # determines the timing option var.
110 tribits_config_code_start_timer(GLOBAL_TIME_START_SECONDS)
111
112 tribits_read_in_native_repositories()
113
114 tribits_combine_native_and_extra_repos()
115
116 tribits_process_extra_repos_options_files()
117
118 include(TribitsInstallationTestingMacros)
119 tribits_find_project_install()
120
121 #
122 # C) Generate version info file and read in ${PROJECT_NAME} packages and
123 # TPLs and process dependencies
124 #
125
126 tribits_generate_repo_version_output_and_file_and_install()
127
128 # Read in and process all of the project's package, TPL, listss and
129 # dependency definition files.
130 tribits_read_all_project_deps_files_create_deps_graph()
131 tribits_print_initial_dependency_info()
132 tribits_write_xml_dependency_files_if_supported()
133
134 #
135 # D) Apply dependency logic to enable and disable TriBITS packages and tests
136 #
137
138 tribits_adjust_and_print_package_dependencies()
139
140 #
141 # E) Stop after all dependencies handling is finished if asked
142 #
143
144 if (${PROJECT_NAME}_SHORTCIRCUIT_AFTER_DEPENDENCY_HANDLING)
145 message("")
146 message("Shortcircuiting after dependency tracking ...")
147 return()
148 endif()
149
150 #
151 # F) Set up the environment on this computer
152 #
153
154 message("")
155 message("Probing the environment ...")
156 message("")
157
158 if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
159 tribits_setup_env()
160 else()
161 message("-- Skipping env setup due to"
162 " ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY=ON")
163 endif()
164
165 #
166 # G) Go get the information for all enabled TPLS
167 #
168
169 tribits_process_enabled_tpls()
170
171 #
172 # H) Set up for testing with CTest and ${PROJECT_NAME} test harness
173 #
174
175 message("")
176 message("Setting up testing support ...")
177 message("")
178
179 if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
180 tribits_include_ctest_support()
181 else()
182 message("-- Skipping testing support setup due to"
183 " ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY=ON")
184 endif()
185
186 #
187 # I) Add the 'dashboard' target
188 #
189 # NOTE: Must come after setting up for testing
190 #
191
192 set(TRIBITS_ADD_DASHBOARD_TARGET_MODULE
193 ${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CTEST_DRIVER_DIR}/TribitsAddDashboardTarget.cmake
194 )
195 if (
196 EXISTS ${TRIBITS_ADD_DASHBOARD_TARGET_MODULE}
197 AND
198 NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY
199 )
200 include(${TRIBITS_ADD_DASHBOARD_TARGET_MODULE})
201 tribits_add_dashboard_target()
202 endif()
203
204 #
205 # J) Configure individual packages
206 #
207
208 message("")
209 message("Configuring individual enabled ${PROJECT_NAME} packages ...")
210 message("")
211
212 if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
213 tribits_repository_configure_all_version_header_files(
214 ${${PROJECT_NAME}_ALL_REPOSITORIES})
215 tribits_repository_configure_all_version_date_files(
216 ${${PROJECT_NAME}_ALL_REPOSITORIES})
217 endif()
218
219 tribits_configure_enabled_packages()
220
221 #
222 # K) Write dummy makefiles for Ninja
223 #
224
225 if (CMAKE_GENERATOR STREQUAL "Ninja")
226
227 if (${PROJECT_NAME}_WRITE_NINJA_MAKEFILES)
228
229 message("")
230 message("Generating dummy makefiles in each directory to call Ninja ...")
231 message("")
232
233 tribits_config_code_start_timer(NINJA_MAKEFILES_TIME_START_SECONDS)
234
235 include(GenerateNinjaMakefiles)
236 generate_ninja_makefiles(${CMAKE_SOURCE_DIR})
237
238 tribits_config_code_stop_timer(NINJA_MAKEFILES_TIME_START_SECONDS
239 "Total time generate Ninja makefiles ${PROJECT_NAME}")
240
241 else()
242
243 message("\nNOTE: *NOT* generating dummy Ninja makefiles (see above note"
244 " and check CMake version)")
245
246 endif()
247
248
249 endif()
250
251 #
252 # L) Setup for packaging and distribution
253 #
254
255 if (${PROJECT_NAME}_ENABLE_CPACK_PACKAGING)
256 message("")
257 message("Set up for creating a distribution ...")
258 message("")
259 if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
260 tribits_setup_packaging_and_distribution()
261 else()
262 message("-- Skipping distribution setup due to"
263 " ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY=ON")
264 endif()
265 else()
266 message("")
267 message("Skipping setup for distribution because"
268 " ${PROJECT_NAME}_ENABLE_CPACK_PACKAGING=OFF")
269 message("")
270 endif()
271
272 #
273 # M) Set up for installation
274 #
275
276 if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
277 tribits_setup_for_installation()
278 endif()
279
280 #
281 # N) Generate resource spec file if applicable
282 #
283
284 tribits_generate_ctest_resource_spec_file_project_logic()
285
286 #
287 # O) Show final timing and end
288 #
289
290 message("")
291 message("Finished configuring ${PROJECT_NAME}!")
292 message("")
293 tribits_config_code_stop_timer(GLOBAL_TIME_START_SECONDS
294 "Total time to configure ${PROJECT_NAME}")
295
296 endmacro()
297
298
299 # @MACRO: tribits_project_enable_all()
300 #
301 # Process a project where you enable all of the packages by default.
302 #
303 # Usage::
304 #
305 # tribits_project_enable_all()
306 #
307 # This macro just sets the global cache var
308 # `${PROJECT_NAME}_ENABLE_ALL_PACKAGES`_ to ``ON`` by default then calls
309 # `tribits_project()`_. That is all. This macro is generally used for
310 # TriBITS projects that have just a single package or by default just want to
311 # enable all packages. This is especially useful when you have a TriBITS
312 # project with just a single package.
313 #
314 macro(tribits_project_enable_all)
315 set(${PROJECT_NAME}_ENABLE_ALL_PACKAGES ON CACHE BOOL "Enable all by default" )
316 tribits_project_impl(${ARGN})
317 endmacro()