1 # ============================================================================ 2 # Copyright (c) 2011-2012 University of Pennsylvania 3 # Copyright (c) 2013-2014 Carnegie Mellon University 4 # Copyright (c) 2013-2016 Andreas Schuh 7 # See COPYING file for license information or visit 8 # https://cmake-basis.github.io/download.html#license 9 # ============================================================================ 11 ############################################################################## 12 # @file ProjectTools.cmake 13 # @brief Definition of main project tools. 14 ############################################################################## 17 # ---------------------------------------------------------------------------- 26 # ============================================================================ 28 # ============================================================================ 30 # --------------------------------------------------------------------------- 31 ## @brief Check if a project name fits the BASIS standards. 34 if (NOT ${INPUT_PROJECT_NAME} MATCHES
"^[a-zA-Z][-+_a-zA-Z0-9]*$")
35 message (FATAL_ERROR
"Invalid name: ${${INPUT_PROJECT_NAME}}\n" 36 "We suggest that you use upper CamelCase notation. " 37 "(see http://en.wikipedia.org/wiki/CamelCase#Variations_and_synonyms). " 38 "Please choose a name with either only captial letters " 39 "in the case of an acronym or a name with mixed case, " 40 "but starting with a (captial) letter.\n" 41 "Note that numbers, `-`, `+`, and `_` are allowed, " 42 "but not as first character.")
46 # ============================================================================ 48 # ============================================================================ 50 ## @brief Auxiliary macro used by basis_project_check_metadata. 52 # Used by basis_project_check_metadata to check the existence of each project 53 # source directory specified in the given list variable and to report an error 54 # otherwise. As a side effect, this macro makes all relative paths absolute 55 # with respect to PROJECT_SOURCE_DIR or sets the directory variable to the 56 # default value (ARGN). 60 foreach (_PATH IN LISTS ${_VAR})
61 if (NOT IS_ABSOLUTE
"${_PATH}")
62 set (_PATH
"${PROJECT_SOURCE_DIR}/${_PATH}")
64 if (NOT IS_DIRECTORY
"${_PATH}")
65 message (FATAL_ERROR
"The ${_VAR} is set to the non-existing path\n\t${_PATH}\n" 66 "Check the basis_project() arguments and keep in mind that" 67 " relative paths have to be relative to the top-level directory" 68 " of the project or module, respectively, i.e.\n\t${PROJECT_SOURCE_DIR}\n")
70 list (APPEND _PATHS
"${_PATH}")
72 set (${_VAR}
"${_PATHS}")
80 # ---------------------------------------------------------------------------- 81 ## @brief Check meta-data and set defaults. 83 # This command sets PROJECT_IS_SUBPROJECT and PROJECT_IS_SUBMODULE. A project 84 # is a (loosely coupled) "subproject" when it uses the SUBPROJECT option of 85 # basis_project to define the name of the subproject. It then also must specify 86 # the name of the PACKAGE this subproject belongs to. When a project uses the 87 # NAME option instead to declare its name, it can be either an independent 88 # project or a (tighly coupled) "submodule" of another project. A project is 89 # regarded a "submodule" when it is not a subproject but specifies a PACKAGE 90 # it belongs to. Otherwise, when a project has only a NAME but no PACKAGE, 91 # the PACKAGE name is set equal the project NAME and the project is regarded 92 # as neither a subproject nor a submodule. When either a subproject or submodule 93 # is built as part of a top-level project (usually the PACKAGE it belongs to), 94 # the CMake variable PROJECT_IS_MODULE is furthermore set to TRUE by the 95 # basis_add_module and basis_add_subdirectory command, respectively. 96 # The boolean PROJECT_IS_SUBPROJECT and PROJECT_IS_SUBMODULE variables are 97 # used by the BASIS commands to decide to which "namespace" the targets of a 98 # project belong to and what components to install. 100 # @sa basis_project() 101 # @sa basis_slicer_module() 104 if (PROJECT_AUTHORS AND PROJECT_AUTHOR)
105 message (FATAL_ERROR
"Options AUTHOR and AUTHORS are mutually exclusive!")
108 set (PROJECT_AUTHORS
"${PROJECT_AUTHOR}")
110 if (NOT PROJECT_AUTHORS AND PROJECT_IS_MODULE)
111 set (PROJECT_AUTHORS
"${TOPLEVEL_PROJECT_AUTHORS}")
113 if (NOT PROJECT_IS_MODULE)
114 set (TOPLEVEL_PROJECT_AUTHORS
"${PROJECT_AUTHORS}")
116 # PROJECT_NAME or PROJECT_SUBPROJECT 117 if (PROJECT_SUBPROJECT AND PROJECT_NAME)
118 message (FATAL_ERROR
"Options SUBPROJECT and NAME are mutually exclusive!")
119 elseif (PROJECT_SUBPROJECT)
120 set (PROJECT_NAME
"${PROJECT_SUBPROJECT}")
121 set (PROJECT_IS_SUBPROJECT TRUE)
123 set (PROJECT_IS_SUBPROJECT FALSE)
125 unset (PROJECT_SUBPROJECT)
126 if (NOT PROJECT_NAME)
127 message (FATAL_ERROR
"CMake BASIS variable PROJECT_NAME not specified!")
130 string (TOLOWER
"${PROJECT_NAME}" PROJECT_NAME_L)
131 string (TOUPPER
"${PROJECT_NAME}" PROJECT_NAME_U)
133 string (TOLOWER
"${PROJECT_NAME_RE}" PROJECT_NAME_RE_L)
134 string (TOUPPER
"${PROJECT_NAME_RE}" PROJECT_NAME_RE_U)
135 if (NOT PROJECT_IS_MODULE)
136 set (TOPLEVEL_PROJECT_NAME
"${PROJECT_NAME}")
137 set (TOPLEVEL_PROJECT_NAME_L
"${PROJECT_NAME_L}")
138 set (TOPLEVEL_PROJECT_NAME_U
"${PROJECT_NAME_U}")
139 set (TOPLEVEL_PROJECT_NAME_RE
"${PROJECT_NAME_RE}")
140 set (TOPLEVEL_PROJECT_NAME_RE_L
"${PROJECT_NAME_RE_L}")
141 set (TOPLEVEL_PROJECT_NAME_RE_U
"${PROJECT_NAME_RE_U}")
143 # PROJECT_PACKAGE_NAME 144 if (PROJECT_PACKAGE AND PROJECT_PACKAGE_NAME)
145 message (FATAL_ERROR
"Options PACKAGE_NAME and PACKAGE are mutually exclusive!")
148 set (PROJECT_PACKAGE_NAME
"${PROJECT_PACKAGE}")
150 if (PROJECT_PACKAGE_NAME AND NOT PROJECT_IS_SUBPROJECT)
151 set (PROJECT_IS_SUBMODULE TRUE)
153 set (PROJECT_IS_SUBMODULE FALSE)
155 if (NOT PROJECT_PACKAGE_NAME)
156 if (PROJECT_IS_MODULE)
157 set (PROJECT_PACKAGE_NAME
"${TOPLEVEL_PROJECT_PACKAGE_NAME}")
159 if (PROJECT_IS_SUBPROJECT)
160 message (FATAL_ERROR
"Missing PACKAGE_NAME option for SUBPROJECT ${PROJECT_NAME}!" 161 " Note that the PACKAGE_NAME option is required for subprojects" 162 " in order to enable the independent build. It should be" 163 " set to the name of the top-level project this subproject" 164 " belongs to. Otherwise, the subproject can only be build" 165 " as part of the package it belongs to.")
167 set (PROJECT_PACKAGE_NAME
"${PROJECT_NAME}")
171 string (TOLOWER
"${PROJECT_PACKAGE_NAME}" PROJECT_PACKAGE_NAME_L)
172 string (TOUPPER
"${PROJECT_PACKAGE_NAME}" PROJECT_PACKAGE_NAME_U)
174 string (TOLOWER
"${PROJECT_PACKAGE_NAME_RE}" PROJECT_PACKAGE_NAME_RE_L)
175 string (TOUPPER
"${PROJECT_PACKAGE_NAME_RE}" PROJECT_PACKAGE_NAME_RE_U)
176 if (NOT PROJECT_IS_MODULE)
177 set (TOPLEVEL_PROJECT_PACKAGE_NAME
"${PROJECT_PACKAGE_NAME}")
178 set (TOPLEVEL_PROJECT_PACKAGE_NAME_L
"${PROJECT_PACKAGE_NAME_L}")
179 set (TOPLEVEL_PROJECT_PACKAGE_NAME_U
"${PROJECT_PACKAGE_NAME_U}")
180 set (TOPLEVEL_PROJECT_PACKAGE_NAME_RE
"${PROJECT_PACKAGE_NAME_RE}")
181 set (TOPLEVEL_PROJECT_PACKAGE_NAME_RE_L
"${PROJECT_PACKAGE_NAME_RE_L}")
182 set (TOPLEVEL_PROJECT_PACKAGE_NAME_RE_U
"${PROJECT_PACKAGE_NAME_RE_U}")
184 # PROJECT_PACKAGE_VENDOR 185 if (PROJECT_PROVIDER AND PROJECT_VENDOR AND PROJECT_PACKAGE_VENDOR)
186 message (FATAL_ERROR
"Options PACKAGE_VENDOR, VENDOR, and PROVIDER (deprecated) are mutually exclusive!")
188 if (PROJECT_PROVIDER)
189 message (WARNING
"Option PROVIDER is deprecated and should be replaced by VENDOR!" 190 " Consider additionally the new options PROVIDER_NAME and DIVISION_NAME")
191 set (PROJECT_PACKAGE_VENDOR
"${PROJECT_PROVIDER}")
194 set (PROJECT_PACKAGE_VENDOR
"${PROJECT_VENDOR}")
196 if (NOT PROJECT_PACKAGE_VENDOR AND PROJECT_IS_MODULE)
197 set (PROJECT_PACKAGE_VENDOR
"${TOPLEVEL_PROJECT_PACKAGE_VENDOR}")
199 string (TOLOWER
"${PROJECT_PACKAGE_VENDOR}" PROJECT_PACKAGE_VENDOR_L)
200 string (TOUPPER
"${PROJECT_PACKAGE_VENDOR}" PROJECT_PACKAGE_VENDOR_U)
201 if (NOT PROJECT_IS_MODULE)
202 set (TOPLEVEL_PROJECT_PACKAGE_VENDOR
"${PROJECT_PACKAGE_VENDOR}")
203 set (TOPLEVEL_PROJECT_PACKAGE_VENDOR_L
"${PROJECT_PACKAGE_VENDOR_L}")
204 set (TOPLEVEL_PROJECT_PACKAGE_VENDOR_U
"${PROJECT_PACKAGE_VENDOR_U}")
206 # PROJECT_PACKAGE_WEBSITE 207 if (PROJECT_WEBSITE AND PROJECT_PACKAGE_WEBSITE)
208 message (FATAL_ERROR
"Options PACKAGE_WEBSITE and WEBSITE are mutually exclusive!")
211 set (PROJECT_PACKAGE_WEBSITE
"${PROJECT_WEBSITE}")
213 if (PROJECT_IS_MODULE)
214 if (NOT PROJECT_PACKAGE_WEBSITE)
215 set (PROJECT_PACKAGE_WEBSITE
"${TOPLEVEL_PROJECT_PACKAGE_WEBSITE}")
218 set (TOPLEVEL_PROJECT_PACKAGE_WEBSITE
"${PROJECT_PACKAGE_WEBSITE}")
220 # PROJECT_PACKAGE_LOGO - see also basis_initialize_settings 221 if (PROJECT_IS_MODULE)
222 if (NOT PROJECT_PACKAGE_LOGO)
223 set (PROJECT_PACKAGE_LOGO
"${TOPLEVEL_PROJECT_PACKAGE_LOGO}")
226 set (TOPLEVEL_PROJECT_PACKAGE_LOGO
"${PROJECT_PACKAGE_LOGO}")
228 # PROJECT_PROVIDER_NAME 229 if (NOT PROJECT_PROVIDER_NAME AND PROJECT_IS_MODULE)
230 set (PROJECT_PROVIDER_NAME
"${TOPLEVEL_PROJECT_PROVIDER_NAME}")
232 string (TOLOWER
"${PROJECT_PROVIDER_NAME}" PROJECT_PROVIDER_NAME_L)
233 string (TOUPPER
"${PROJECT_PROVIDER_NAME}" PROJECT_PROVIDER_NAME_U)
234 if (NOT PROJECT_IS_MODULE)
235 set (TOPLEVEL_PROJECT_PROVIDER_NAME
"${PROJECT_PROVIDER_NAME}")
236 set (TOPLEVEL_PROJECT_PROVIDER_NAME_L
"${PROJECT_PROVIDER_NAME_L}")
237 set (TOPLEVEL_PROJECT_PROVIDER_NAME_U
"${PROJECT_PROVIDER_NAME_U}")
239 # PROJECT_PROVIDER_WEBSITE 240 if (PROJECT_IS_MODULE)
241 if (NOT PROJECT_PROVIDER_WEBSITE)
242 set (PROJECT_PROVIDER_WEBSITE
"${TOPLEVEL_PROJECT_PROVIDER_WEBSITE}")
245 set (TOPLEVEL_PROJECT_PROVIDER_WEBSITE
"${PROJECT_PROVIDER_WEBSITE}")
247 # PROJECT_PROVIDER_LOGO - see also basis_initialize_settings 248 if (PROJECT_IS_MODULE)
249 if (NOT PROJECT_PROVIDER_LOGO)
250 set (PROJECT_PROVIDER_LOGO
"${TOPLEVEL_PROJECT_PROVIDER_LOGO}")
253 set (TOPLEVEL_PROJECT_PROVIDER_LOGO
"${PROJECT_PROVIDER_LOGO}")
255 # PROJECT_DIVISION_NAME 256 if (NOT PROJECT_DIVISION_NAME AND PROJECT_IS_MODULE)
257 set (PROJECT_DIVISION_NAME
"${TOPLEVEL_PROJECT_DIVISION_NAME}")
259 string (TOLOWER
"${PROJECT_DIVISION_NAME}" PROJECT_DIVISION_NAME_L)
260 string (TOUPPER
"${PROJECT_DIVISION_NAME}" PROJECT_DIVISION_NAME_U)
261 if (NOT PROJECT_IS_MODULE)
262 set (TOPLEVEL_PROJECT_DIVISION_NAME
"${PROJECT_DIVISION_NAME}")
263 set (TOPLEVEL_PROJECT_DIVISION_NAME_L
"${PROJECT_DIVISION_NAME_L}")
264 set (TOPLEVEL_PROJECT_DIVISION_NAME_U
"${PROJECT_DIVISION_NAME_U}")
266 # PROJECT_DIVISION_WEBSITE 267 if (PROJECT_IS_MODULE)
268 if (NOT PROJECT_DIVISION_WEBSITE)
269 set (PROJECT_DIVISION_WEBSITE
"${TOPLEVEL_PROJECT_DIVISION_WEBSITE}")
272 set (TOPLEVEL_PROJECT_DIVISION_WEBSITE
"${PROJECT_DIVISION_WEBSITE}")
274 # PROJECT_DIVISION_LOGO - see also basis_initialize_settings 275 if (PROJECT_IS_MODULE)
276 if (NOT PROJECT_DIVISION_LOGO)
277 set (PROJECT_DIVISION_LOGO
"${TOPLEVEL_PROJECT_DIVISION_LOGO}")
280 set (TOPLEVEL_PROJECT_DIVISION_LOGO
"${PROJECT_DIVISION_LOGO}")
282 # PROJECT_SOVERSION -- **BEFORE** setting PROJECT_VERSION! 283 if (
"^${PROJECT_SOVERSION}$" STREQUAL
"^$")
284 if (PROJECT_IS_MODULE AND
"^${PROJECT_VERSION}$" STREQUAL
"^$")
285 set (PROJECT_SOVERSION
"${TOPLEVEL_PROJECT_SOVERSION}")
288 if (NOT PROJECT_SOVERSION MATCHES
"^[0-9]+(\\.[0-9]+)?$")
289 message (FATAL_ERROR
"Project ${PROJECT_NAME} has invalid API version: ${PROJECT_SOVERSION}!")
291 if (NOT PROJECT_IS_MODULE)
292 set (TOPLEVEL_PROJECT_SOVERSION
"${PROJECT_SOVERSION}")
296 if (NOT
"^${PROJECT_VERSION}$" STREQUAL
"^$")
297 if (NOT PROJECT_VERSION MATCHES
"^[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?(rc[0-9]+|[a-z])?$")
298 message (FATAL_ERROR
"Project ${PROJECT_NAME} has invalid version: ${PROJECT_VERSION}!")
300 if (PROJECT_IS_MODULE)
301 if (PROJECT_VERSION MATCHES
"^0+(\\.0+)?(\\.0+)?$")
302 set (PROJECT_VERSION
"${TOPLEVEL_PROJECT_VERSION}")
305 set (TOPLEVEL_PROJECT_VERSION
"${PROJECT_VERSION}")
308 if (PROJECT_IS_MODULE)
309 set (PROJECT_VERSION
"${TOPLEVEL_PROJECT_VERSION}")
311 message (FATAL_ERROR
"Project version not specified!")
314 # PROJECT_DESCRIPTION 315 if (PROJECT_DESCRIPTION)
318 set (PROJECT_DESCRIPTION
"")
321 if (PROJECT_IS_MODULE)
322 if (NOT PROJECT_COPYRIGHT)
323 set (PROJECT_COPYRIGHT
"${TOPLEVEL_PROJECT_COPYRIGHT}")
326 set (TOPLEVEL_PROJECT_COPYRIGHT
"${PROJECT_COPYRIGHT}")
329 if (PROJECT_IS_MODULE)
330 if (NOT PROJECT_LICENSE)
331 set (PROJECT_LICENSE
"${TOPLEVEL_PROJECT_LICENSE}")
334 set (TOPLEVEL_PROJECT_LICENSE
"${PROJECT_LICENSE}")
337 if (PROJECT_IS_MODULE)
338 if (NOT PROJECT_CONTACT)
339 set (PROJECT_CONTACT
"${TOPLEVEL_PROJECT_CONTACT}")
342 set (TOPLEVEL_PROJECT_CONTACT
"${PROJECT_CONTACT}")
345 if (PROJECT_IS_MODULE)
346 if (NOT PROJECT_LANGUAGES)
347 set (PROJECT_LANGUAGES
"${TOPLEVEL_PROJECT_LANGUAGES}")
350 if (NOT PROJECT_LANGUAGES)
351 set (PROJECT_LANGUAGES C
CXX)
353 set (TOPLEVEL_PROJECT_LANGUAGES
"${PROJECT_LANGUAGES}")
355 # PROJECT_DEFAULT_MODULES 356 if (PROJECT_IS_MODULE)
357 if (PROJECT_DEFAULT_MODULES)
358 message (FATAL_ERROR
"Module ${PROJECT_NAME} specified DEFAULT_MODULES, but a module cannot have itself modules.")
360 set (PROJECT_DEFAULT_MODULES
"${TOPLEVEL_PROJECT_DEFAULT_MODULES}")
363 if (NOT PROJECT_DEFAULT_MODULES)
364 set (PROJECT_DEFAULT_MODULES
"")
366 set (TOPLEVEL_PROJECT_DEFAULT_MODULES
"${PROJECT_DEFAULT_MODULES}")
368 # PROJECT_EXTERNAL_MODULES 369 if (PROJECT_IS_MODULE)
370 if (PROJECT_EXTERNAL_MODULES)
371 message (FATAL_ERROR
"Module ${PROJECT_NAME} specified EXTERNAL_MODULES, but a module cannot have itself modules.")
373 set (PROJECT_EXTERNAL_MODULES
"${TOPLEVEL_PROJECT_EXTERNAL_MODULES}")
376 if (NOT PROJECT_EXTERNAL_MODULES)
377 set (PROJECT_EXTERNAL_MODULES
"")
379 set (TOPLEVEL_PROJECT_EXTERNAL_MODULES
"${PROJECT_EXTERNAL_MODULES}")
381 # PROJECT_EXCLUDE_FROM_ALL 382 if (PROJECT_IS_MODULE)
383 if (NOT DEFINED PROJECT_EXCLUDE_FROM_ALL)
384 set (PROJECT_EXCLUDE_FROM_ALL FALSE)
387 if (PROJECT_EXCLUDE_FROM_ALL)
388 message (FATAL_ERROR
"EXCLUDE_FROM_ALL option only valid for project modules.")
391 # prefix used for CMake variables in <Pkg>[<Module>]Config.cmake (cf. GenerateConfig.cmake) 392 if (PROJECT_IS_SUBMODULE)
393 set (PROJECT_CONFIG_PREFIX
"${PROJECT_PACKAGE_NAME}_${PROJECT_NAME}")
394 elseif (PROJECT_IS_MODULE OR PROJECT_IS_SUBPROJECT)
395 set (PROJECT_CONFIG_PREFIX
"${PROJECT_NAME}")
397 set (PROJECT_CONFIG_PREFIX
"${PROJECT_PACKAGE_NAME}")
399 # source tree directories aliases 400 if (PROJECT_INCLUDE_DIR)
403 if (PROJECT_CODE_DIR)
406 if (PROJECT_TOOLS_DIR)
407 list (INSERT PROJECT_TOOLS_DIRS 0
"${PROJECT_TOOLS_DIR}")
409 # source tree directories 422 # PROJECT_HAS_APPLICATIONS 423 set (PROJECT_HAS_APPLICATIONS FALSE)
424 foreach (
DIR IN LISTS PROJECT_TOOLS_DIRS)
425 if (EXISTS
"${DIR}/CMakeLists.txt")
426 set (PROJECT_HAS_APPLICATIONS TRUE)
430 # extract main source code directories from lists 431 list (GET PROJECT_INCLUDE_DIRS 0 PROJECT_INCLUDE_DIR)
432 list (GET PROJECT_CODE_DIRS 0 PROJECT_CODE_DIR)
433 list (GET PROJECT_TOOLS_DIRS 0 PROJECT_TOOLS_DIR)
434 # make OTHER_DIRS paths absolute and append deprecated SUBDIRS argument 437 if (NOT IS_ABSOLUTE
"${_PATH}")
438 set (_PATH
"${PROJECT_SOURCE_DIR}/${_PATH}")
440 list (APPEND _OTHER_DIRS
"${_PATH}")
442 set (PROJECT_OTHER_DIRS ${_OTHER_DIRS})
443 unset(PROJECT_SUBDIRS)
446 # let basis_project_begin() know that basis_project() was called 447 set (BASIS_basis_project_CALLED TRUE)
450 # ---------------------------------------------------------------------------- 451 ## @brief Sets basic project information including the name, version, and dependencies. 453 # Any BASIS project has to call this macro in the file BasisProject.cmake 454 # located in the top level directory of the source tree in order to define 455 # the project attributes required by BASIS to setup the build system. 456 # Moreover, if the BASIS project is a module of another BASIS project, this 457 # file and the variables set by this macro are used by the top-level project to 458 # identify its modules and the dependencies among them. 460 # @param [in] ARGN This list is parsed for the following arguments: 462 # @par General project meta-data: 466 # @tp @b VERSION major[.minor[.patch]] @endtp 467 # <td>Project version string. (default: 1.0.0) 469 # The version number consists of three components: the major version number, 470 # the minor version number, and the patch number. The format of the version 471 # string is "<major>.<minor>.<patch>", where the minor version number and patch 472 # number default to "0" if not given. Only digits are allowed except of the two 475 # - A change of the major version number indicates changes of the softwares 476 # @api (and @abi) and/or its behavior and/or the change or addition of major 478 # - A change of the minor version number indicates changes that are not only 479 # bug fixes and no major changes. Hence, changes of the @api but not the @abi. 480 # - A change of the patch number indicates changes only related to bug fixes 481 # which did not change the softwares @api. It is the least important component 482 # of the version number. 486 # @tp @b SOVERSION major @endtp 487 # <td>Explicit SOVERSION of shared libraries, must be an integer. 488 # A value of 0 indicates that the API is yet unstable. 489 # (default: PROJECT_VERSION_MAJOR)</td> 492 # @tp @b DESCRIPTION description @endtp 493 # <td>Package description, used for packing. If multiple arguments are given, 494 # they are concatenated using one space character as delimiter.</td> 497 # @tp @b NAME name @endtp 498 # <td>The name of the project.</td> 501 # @tp @b SUBPROJECT name @endtp 502 # <td>Use this option instead of @c NAME to indicate that this project is a subproject 503 # of the package named by @c PACKAGE_NAME. This results, for example, in target 504 # UIDs such as "<package>.<name>.<target>" instead of "<package>.<target>". 505 # Moreover, the libraries and shared files of a subproject are installed 506 # in subdirectores whose name equals the name of the subproject. This option 507 # should only be used for projects which are modules of another BASIS project, 508 # where these modules should reside in their own sub-namespace rather than 509 # on the same level as the top-level project.</td> 512 # @tp @b PACKAGE_NAME name @endtp 513 # <td>Name of the package this project (module) belongs to. Defaults to the 514 # name of the (top-level) project. This option can further be used in case 515 # of a top-level project to specify a different package name for the installation. 516 # In case of a subproject which is a module of another BASIS project, setting 517 # the package name explicitly using this option enables the build of the 518 # subproject as separate project while preserving the directory structure 519 # and other namespace settings. Therefore, this option is required if the 520 # @c SUBPROJECT option is given and the project shall be build independently 521 # as stand-alone package. (default: name of top-level package)</td> 524 # @tp @b PACKAGE name @endtp 525 # <td>Short alternative for @c PACKAGE_NAME.</td> 528 # @tp @b PACKAGE_VENDOR name @endtp 529 # <td>Short ID of package vendor (i.e, provider and/or division acronym) this variable is used 530 # for package identification and is the name given to the folder that will be used as the default 531 # installation path location subdirectory.</td> 534 # @tp @b VENDOR name @endtp 535 # <td>Short alternative for @c PACKAGE_VENDOR.</td> 538 # @tp @b PACKAGE_WEBSITE url @endtp 539 # <td>URL of project website used for documentation and packaging. 540 # (default: project website of top-level project or empty string)</td> 543 # @tp @b PACKAGE_LOGO path @endtp 544 # <td>Path to package logo file for this installable package. Used in documentation and packaging. 545 # Relative paths must be relative to @c PROJECT_SOURCE_DIR. 546 # (default: empty string)</td> 549 # @tp @b WEBSITE url @endtp 550 # <td>Short alternative for @c PACKAGE_WEBSITE.</td> 553 # @tp @b PROVIDER_NAME name @endtp 554 # <td>The provider/vendor/creator of this package, used for packaging and installation. 555 # (default: provider of top-level project or empty string)</td> 558 # @tp @b PROVIDER_WEBSITE url @endtp 559 # <td>URL of provider website used for documentation and packaging. 560 # (default: provider website of top-level project or empty string)</td> 563 # @tp @b PROVIDER_LOGO path @endtp 564 # <td>Path to provider logo file used for documentation and packaging. 565 # Relative paths must be relative to @c PROJECT_SOURCE_DIR. 566 # (default: empty string)</td> 569 # @tp @b DIVISION_NAME name @endtp 570 # <td>The provider division of this package, used for packaging and installation. 571 # (default: provider division of top-level project or empty string)</td> 574 # @tp @b DIVISION_WEBSITE url @endtp 575 # <td>URL of provider division website used for documentation and packaging. 576 # (default: provider website of top-level project or empty string)</td> 579 # @tp @b DIVISION_LOGO path @endtp 580 # <td>Path to provider division logo file used for documentation and packaging. 581 # Relative paths must be relative to @c PROJECT_SOURCE_DIR. 582 # (default: empty string)</td> 585 # @tp @b LANGUAGES lang1 [lang2...] @endtp 586 # <td>Programming languages used by the project. For example, CXX for C++ or 587 # CXX-11 for C++11. When C++11 is used, the respective compiler flag 588 # such as -std=c++11 is added to the compile flags. Those languages supported 589 # by CMake itself are further passed on to CMake's project command.</td> 592 # @tp @b DEFAULT_MODULES module1 [module2...] @endtp 593 # <td>List of project modules that should be enabled by default. 594 # The single value "ALL" can be used to enable all modules.<.td> 597 # @tp @b EXTERNAL_MODULES module1 [module2...] @endtp 598 # <td>List of external project modules. Only required when directory of external 599 # modules may be empty (i.e., not contain a BasisProject.cmake file) as in 600 # case of an uninitialized Git submodule.<.td> 603 # @tp @b EXCLUDE_FROM_ALL @endtp 604 # <td>Exclude this project module from @c BUILD_ALL_MODULES.</td> 607 # @tp @b TEMPLATE path @endtp 608 # <td> The TEMPLATE variable stores the directory of the chosen project template along 609 # with the template version so that the correct template is used by basisproject when a project is updated. 610 # Note that this variable is used in BASIS itself to specify the default template to use for the BASIS 611 # installation, i.e., the default used by basisproject if no --template argument is provided. 612 # If the template is part of the BASIS installation, only the template name and version part of the 613 # full path are needed. Otherwise, the full absolute path is used. For example, 617 # TEMPLATE "sbia/1.8" 623 # TEMPLATE "/opt/local/share/custom-basis-template/1.0" 627 # The installed templates can be found in the share/templates folder of installed BASIS software, 628 # as well as the data/templates foler of the BASIS source tree.</td> 632 # @par Project dependencies: 633 # Dependencies on other BASIS projects, which can be subprojects of the same 634 # BASIS top-level project, as well as dependencies on external packages such as ITK 635 # have to be defined here using the @p DEPENDS argument option. This will be used 636 # by a top-level project to ensure that the dependencies among its subprojects are 637 # resolved properly. For each external dependency, the BASIS functions 638 # basis_find_package() and basis_use_package() are invoked by 639 # basis_project_initialize(). If an external package is not CMake aware and 640 # additional CMake code shall be executed to include the settings of the external 641 # package (which is usually done in a so-called <tt>Use<Pkg>.cmake</tt> file 642 # if the package would be CMake aware), such code should be added to the 643 # <tt>Settings.cmake</tt> file of the project. 647 # @tp @b DEPENDS dep1 [dep2...] @endtp 648 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 649 # or names of external packages.</td> 652 # @tp @b OPTIONAL_DEPENDS dep1 [dep2...] @endtp 653 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 654 # or names of external packages which are used only if available.</td> 657 # @tp @b TOOLS_DEPENDS dep1 [dep2...] @endtp 658 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 659 # or names of external packages required when BUILD_APPLICATIONS is ON.</td> 662 # @tp @b OPTIONAL_TOOLS_DEPENDS dep1 [dep2...] @endtp 663 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 664 # or names of external packages which are used only if available 665 # when BUILD_APPLICATIONS is ON.</td> 668 # @tp @b TEST_DEPENDS dep1 [dep2...] @endtp 669 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 670 # or names of external packages which are only required by the tests.</td> 673 # @tp @b OPTIONAL_TEST_DEPENDS dep1 [dep2...] @endtp 674 # <td>List of dependencies, i.e., either names of other BASIS (sub)projects 675 # or names of external packages which are used only by the tests if available.</td> 679 # @par Source tree layout: 680 # Relative directory paths have to be relative to the @c PROJECT_SOURCE_DIR, i.e., 681 # the diretory containing the @c BasisProject.cmake file which calls this command. 682 # If any of the following arguments refer to non-existing directory paths, 683 # the respective paths are simply ignored during the project build configuration. 684 # In case of the paths passed to @p MODULE_DIRS, an error is raised if the directory 685 # does not exist or is missing a BasisProject.cmake file. 689 # @tp @b INCLUDE_DIRS path1 [path2...] @endtp 690 # <td>A list of directories containing the header files of the public interface. 691 # (default: include)</td> 694 # @tp @b INCLUDE_DIR path @endtp 695 # <td>Alternative option for @p INCLUDE_DIRS which only accepts a single path as argument.</td> 698 # @tp @b CODE_DIRS path1 [path2...] @endtp 699 # <td>A list of directories containing the source code files. The first diretory path 700 # is used as main source directory from which the subdirectory name of the 701 # corresponding build tree directory is derived. Any configured or generated 702 # source files are written to this build tree source directory. 703 # (default: src)</td> 706 # @tp @b CODE_DIR path @endtp 707 # <td>Alternative option for @p CODE_DIRS which only accepts a single path as argument.</td> 710 # @tp @b TOOLS_DIRS path1 [path2...] @endtp 711 # <td>A list of directories containing the source code files of applications. 712 # The first diretory path is used as main source directory from which the 713 # subdirectory name of the corresponding build tree directory is derived. 714 # Any configured or generated source files are written to this build tree 715 # source directory. The source files in the specified directories are only 716 # build when the BUILD_APPLICATIONS option is enabled. This option is 717 # automatically added when any of the directories contains a CMakeLists.txt 718 # file. (default: tools)</td> 721 # @tp @b TOOLS_DIR path @endtp 722 # <td>Alternative option for @p TOOLS_DIRS which only accepts a single path as argument.</td> 725 # @tp @b LIBRARY_DIR path @endtp 726 # <td>Directory of public modules written in a scripting language such as Python or Perl. (default: lib)</td> 729 # @tp @b MODULES_DIR path @endtp 730 # <td>Path to directory containing multiple module subdirectories, each containing 731 # their own BasisProject.cmake file that will each be picked up automatically. 732 # (default: modules)</td> 735 # @tp @b MODULE_DIRS path1 [path2...] @endtp 736 # <td>A list of individual module directories, each containing a BasisProject.cmake file. 737 # This list differs from @c MODULES_DIR in that each listed directory is the 738 # root directory of a single module, whereas @c MODULES_DIR is the comman 739 # directory of multiple modules contained in their own respective subdirectory. 743 # @tp @b CONFIG_DIR path @endtp 744 # <td>Directory in which BASIS looks for custom CMake/BASIS configuration files. (default: config)</td> 747 # @tp @b DATA_DIR path @endtp 748 # <td>Directory which contains auxiliary data required by the software programs. (default: data)</td> 751 # @tp @b DOC_DIR path @endtp 752 # <td>Directory containing the software documentation (source) files. (default: doc)</td> 755 # @tp @b DOCRES_DIR path @endtp 756 # <td>Directory where the documentation ressource files such as the project logo are located. (default: @p DOC_DIR/config)</td> 759 # @tp @b EXAMPLE_DIR path @endtp 760 # <td>Directory with some example files demonstrating the usage of the software. (default: example)</td> 763 # @tp @b TESTING_DIR path @endtp 764 # <td>The root diretory of the testing source tree containing test data and implementations. (default: test)</td> 767 # @tp @b OTHER_DIRS path... @endtp 768 # <td>List of other project directories with CMakeLists.txt files in them. (default: none)</td> 772 # @returns Sets the following non-cached CMake variables. 773 # See documentation of the corresponding parameters above for details. 774 # @retval PROJECT_NAME See @c NAME and @p SUBPROJECT. 775 # @retval PROJECT_PACKAGE_NAME See @c PACKAGE_NAME. 776 # @retval PROJECT_PACKAGE_VENDOR See @c PACKAGE_VENDOR. 777 # @retval PROJECT_PACKAGE_WEBSITE See @c PACKAGE_WEBSITE. 778 # @retval PROJECT_PACKAGE_LOGO See @c PACKAGE_LOGO. Value is an absolute path. 779 # @retval PROJECT_PROVIDER_NAME See @c PROVIDER_NAME. 780 # @retval PROJECT_PROVIDER_WEBSITE See @c PROVIDER_WEBSITE. 781 # @retval PROJECT_PROVIDER_LOGO See @c PROVIDER_LOGO. Value is an absolute path. 782 # @retval PROJECT_DIVISION_NAME See @c DIVISION_NAME. 783 # @retval PROJECT_DIVISION_WEBSITE See @c DIVISION_WEBSITE. 784 # @retval PROJECT_DIVISION_LOGO See @c DIVISION_LOGO. Value is an absolute path. 785 # @retval PROJECT_VERSION See @c VERSION. 786 # @retval PROJECT_SOVERSION See @c SOVERSION. 787 # @retval PROJECT_DESCRIPTION See @c DESCRIPTION. 788 # @retval PROJECT_LANGUAGES See @c LANGUAGES. 789 # @retval PROJECT_DEPENDS See @c DEPENDS. 790 # @retval PROJECT_OPTIONAL_DEPENDS See @c OPTIONAL_DEPENDS. 791 # @retval PROJECT_TOOLS_DEPENDS See @c TOOLS_DEPENDS. 792 # @retval PROJECT_OPTIONAL_TOOLS_DEPENDS See @c OPTIONAL_TOOLS_DEPENDS. 793 # @retval PROJECT_TEST_DEPENDS See @c TEST_DEPENDS. 794 # @retval PROJECT_OPTIONAL_TEST_DEPENDS See @c OPTIONAL_TEST_DEPENDS. 795 # @retval PROJECT_IS_SUBPROJECT @c TRUE if @c SUBPROJECT used instead of NAME or @c FALSE otherwise. 796 # @retval PROJECT_IS_SUBMODULE @c TRUE when project @c NAME and @c PACKAGE name is given, @c FALSE otherwise. 797 # @retval PROJECT_DEFAULT_MODULES See @c DEFAULT_MODULES. 798 # @retval PROJECT_EXTERNAL_MODULES See @c EXTERNAL_MODULES. 800 # @retval PROJECT_CODE_DIRS See @c CODE_DIRS. 801 # @retval PROJECT_CODE_DIR First element of @c PROJECT_CODE_DIRS list. 802 # @retval PROJECT_TOOLS_DIRS See @c TOOLS_DIRS. 803 # @retval PROJECT_TOOLS_DIR First element of @c PROJECT_TOOLS_DIRS list. 804 # @retval PROJECT_CONFIG_DIR See @c CONFIG_DIR. 805 # @retval PROJECT_DATA_DIR See @c DATA_DIR. 806 # @retval PROJECT_DOC_DIR See @c DOC_DIR. 807 # @retval PROJECT_DOCRES_DIR See @c DOCRES_DIR. 808 # @retval PROJECT_EXAMPLE_DIR See @c EXAMPLE_DIR. 809 # @retval PROJECT_INCLUDE_DIRS See @c INCLUDE_DIRS. 810 # @retval PROJECT_INCLUDE_DIR First element of @c PROJECT_INCLUDE_DIRS list. 811 # @retval PROJECT_LIBRARY_DIR See @c LIBRARY_DIR. 812 # @retval PROJECT_MODULE_DIRS See @c MODULE_DIRS. 813 # @retval PROJECT_MODULES_DIR See @c MODULES_DIR. 814 # @retval PROJECT_TESTING_DIR See @c TESTING_DIR. 815 # @retval PROJECT_OTHER_DIRS See @c OTHER_DIRS. 817 # @retval PROJECT_HAS_APPLICATIONS Whether any of the PROJECT_TOOLS_DIRS has a CMakeLists.txt file. 821 # @see BasisSettings.cmake 823 # @see BasisSettings.cmake for parameter lists. 824 # @see basis_project_check_metadata() above for implementation details 825 CMAKE_PARSE_ARGUMENTS (
827 "${BASIS_METADATA_LIST_SWITCH}" 828 "${BASIS_METADATA_LIST_SINGLE}" 829 "${BASIS_METADATA_LIST_MULTI}" 836 ## @addtogroup CMakeUtilities 840 # ============================================================================ 842 # ============================================================================ 844 # ---------------------------------------------------------------------------- 845 ## @brief Ensure certain requirements on build tree. 848 # - Root of build tree must not be root of source tree. 850 # @param [in] ARGN Not used. 854 string (TOLOWER
"${CMAKE_SOURCE_DIR}" SOURCE_ROOT)
855 string (TOLOWER
"${CMAKE_BINARY_DIR}" BUILD_ROOT)
856 if (
"^${BUILD_ROOT}$" STREQUAL
"^${SOURCE_ROOT}$")
857 message(FATAL_ERROR
"This project should not be configured & build in the " 858 "source directory:\n" 859 " ${CMAKE_SOURCE_DIR}\n" 860 "You must run CMake in a separate build directory.")
864 # ---------------------------------------------------------------------------- 865 ## @brief Ensure certain requirements on install tree. 868 # - Prefix must be an absolute path. 869 # - Install tree must be different from source and build tree. 871 # @param [in] ARGN Not used. 875 if (NOT IS_ABSOLUTE
"${CMAKE_INSTALL_PREFIX}")
876 message (FATAL_ERROR
"CMAKE_INSTALL_PREFIX must be an absolute path!")
878 string (TOLOWER
"${CMAKE_SOURCE_DIR}" SOURCE_ROOT)
879 string (TOLOWER
"${CMAKE_BINARY_DIR}" BUILD_ROOT)
880 string (TOLOWER
"${CMAKE_INSTALL_PREFIX}" INSTALL_ROOT)
881 if (
"^${BUILD_ROOT}$" STREQUAL
"^${INSTALL_ROOT}$" OR
"^${SOURCE_ROOT}$" STREQUAL
"^${INSTALL_ROOT}$")
882 message (FATAL_ERROR
"The current CMAKE_INSTALL_PREFIX points at the source or build tree:\n" 883 " ${CMAKE_INSTALL_PREFIX}\n" 884 "This is not permitted by this project. " 885 "Please choose another installation prefix." 890 # ---------------------------------------------------------------------------- 891 # @brief Obtain module info from BasisProject.cmake file 893 # Use function scope to avoid overwriting of this project's variables. 897 # include BasisProject.cmake file 898 set (PROJECT_IS_MODULE TRUE)
900 set (BASIS_basis_project_CALLED FALSE)
902 # make sure that basis_project() was called 903 if (NOT BASIS_basis_project_CALLED)
904 message (FATAL_ERROR
"basis_module_info(): Missing basis_project() command in ${F}!")
906 # remember dependencies 907 foreach (V IN ITEMS DEPENDS OPTIONAL_DEPENDS TOOLS_DEPENDS OPTIONAL_TOOLS_DEPENDS TEST_DEPENDS OPTIONAL_TEST_DEPENDS)
909 foreach (D ${PROJECT_${V}})
911 if (
"^${PKG}$" STREQUAL
"^${TOPLEVEL_PROJECT_NAME}$")
912 list (APPEND ${V} ${CMPS})
914 list (APPEND ${V}
"${PKG}")
918 # do not use MODULE instead of PROJECT_NAME in this function as it is not 919 # set in the scope of this function but its parent scope only 920 set (${PROJECT_NAME}_DEPENDS
"${DEPENDS}" PARENT_SCOPE)
921 set (${PROJECT_NAME}_OPTIONAL_DEPENDS
"${OPTIONAL_DEPENDS}" PARENT_SCOPE)
922 set (${PROJECT_NAME}_TOOLS_DEPENDS
"${TOOLS_DEPENDS}" PARENT_SCOPE)
923 set (${PROJECT_NAME}_OPTIONAL_TOOLS_DEPENDS
"${OPTIONAL_TOOLS_DEPENDS}" PARENT_SCOPE)
924 set (${PROJECT_NAME}_TEST_DEPENDS
"${TEST_DEPENDS}" PARENT_SCOPE)
925 set (${PROJECT_NAME}_OPTIONAL_TEST_DEPENDS
"${OPTIONAL_TEST_DEPENDS}" PARENT_SCOPE)
926 set (${PROJECT_NAME}_DECLARED TRUE PARENT_SCOPE)
927 set (${PROJECT_NAME}_MISSING FALSE PARENT_SCOPE)
928 set (${PROJECT_NAME}_IS_SUBPROJECT
"${PROJECT_IS_SUBPROJECT}" PARENT_SCOPE)
929 set (${PROJECT_NAME}_IS_SUBMODULE
"${PROJECT_IS_SUBMODULE}" PARENT_SCOPE)
930 set (${PROJECT_NAME}_CONFIG_PREFIX
"${PROJECT_CONFIG_PREFIX}" PARENT_SCOPE)
932 set (${PROJECT_NAME}_INCLUDE_DIRS
"${PROJECT_INCLUDE_DIRS}" PARENT_SCOPE)
933 set (${PROJECT_NAME}_CODE_DIRS
"${PROJECT_CODE_DIRS}" PARENT_SCOPE)
935 if (PROJECT_IS_SLICER_MODULE)
936 foreach (_D IN LISTS BASIS_SLICER_METADATA_LIST)
937 if (DEFINED PROJECT_${_D})
938 set (${PROJECT_NAME}_${_D}
"${PROJECT_${_D}}" PARENT_SCOPE)
941 set (${PROJECT_NAME}_IS_SLICER_MODULE TRUE PARENT_SCOPE)
943 set (${PROJECT_NAME}_IS_SLICER_MODULE FALSE PARENT_SCOPE)
945 # whether to always exclude module from BUILD_ALL_MODULES 946 set (${PROJECT_NAME}_EXCLUDE_FROM_ALL
"${PROJECT_EXCLUDE_FROM_ALL}" PARENT_SCOPE)
948 set (${MODULE_NAME}
"${PROJECT_NAME}" PARENT_SCOPE)
951 # ---------------------------------------------------------------------------- 952 ## @brief Manually add project module to list of modules 954 # clean path without // to fix issue with UNC paths on Windows 957 list (APPEND PROJECT_MODULES ${
_MODULE})
960 set (MODULE_${
_MODULE}_SOURCE_DIR
"${${_MODULE}_BASE}")
961 set (MODULE_${
_MODULE}_BINARY_DIR
"${CMAKE_CURRENT_BINARY_DIR}/${${_MODULE}_BASE_REL}")
962 set (${MODULE_NAME} ${
_MODULE})
966 # ---------------------------------------------------------------------------- 967 ## @brief Initialize project modules. 969 # Most parts of this macro were copied from the ITK4 project 970 # (http://www.vtk.org/Wiki/ITK_Release_4), in particular, the top-level 971 # CMakeLists.txt file. This file does not state any specific license, but 972 # the ITK package itself is released under the Apache License Version 2.0, 973 # January 2004 (http://www.apache.org/licenses/). 975 # -------------------------------------------------------------------------- 977 set (PROJECT_MODULES)
980 # --------------------------------------------------------------------------
983 # glob BasisProject.cmake files in modules subdirectory
985 file (GLOB_RECURSE MODULE_INFO_FILES
"${PROJECT_MODULES_DIR}/*/BasisProject.cmake")
988 # add each manually specified module 990 if (NOT IS_ABSOLUTE ${_PATH})
991 set (_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/${_PATH}")
993 if (EXISTS
"${_PATH}/BasisProject.cmake")
994 list (APPEND MODULE_INFO_FILES
"${_PATH}/BasisProject.cmake")
997 list(FIND PROJECT_EXTERNAL_MODULES
"${MODULE}" IDX)
999 message (FATAL_ERROR
"Check your top-level ${CMAKE_CURRENT_SOURCE_DIR}/BasisProject.cmake" 1000 " file because the module ${_PATH}/BasisProject.cmake" 1001 " file does not appear to exist.")
1007 set (PROJECT_MODULES)
1008 foreach (F IN LISTS MODULE_INFO_FILES)
1009 # import module info into current scope 1012 set (${MODULE}_DIR
"${MODULE_${MODULE}_BINARY_DIR}")
1013 # only
set EXCLUDE_<MODULE>_FROM_ALL when not specified on command-line
using -D
switch 1014 if (NOT DEFINED EXCLUDE_${MODULE}_FROM_ALL)
1015 set (EXCLUDE_${MODULE}_FROM_ALL
"${${MODULE}_EXCLUDE_FROM_ALL}")
1019 # add non-existing external modules to list 1020 foreach (MODULE IN LISTS PROJECT_EXTERNAL_MODULES)
1021 if (NOT ${MODULE}_DECLARED)
1022 list (APPEND PROJECT_MODULES
"${MODULE}")
1023 set (${MODULE}_DEPENDS)
1024 set (${MODULE}_OPTIONAL_DEPENDS)
1025 set (${MODULE}_TOOLS_DEPENDS)
1026 set (${MODULE}_OPTIONAL_TOOLS_DEPENDS)
1027 set (${MODULE}_TEST_DEPENDS)
1028 set (${MODULE}_OPTIONAL_TEST_DEPENDS)
1029 set (${MODULE}_DECLARED TRUE)
1030 set (${MODULE}_MISSING TRUE)
1034 # validate the module DAG to identify cyclic dependencies 1035 macro (basis_module_check MODULE NEEDED_BY STACK)
1036 if (${MODULE}_DECLARED)
1037 if (${MODULE}_CHECK_STARTED AND NOT ${MODULE}_CHECK_FINISHED)
1038 # we reached a module
while traversing its own dependencies recursively
1040 foreach (M ${STACK})
1041 set (MSG
" ${M} =>${MSG}")
1042 if (
"${M}" STREQUAL
"${MODULE}")
1046 message (FATAL_ERROR
"Module dependency cycle detected:\n ${MSG} ${MODULE}")
1047 elseif (NOT ${MODULE}_CHECK_STARTED)
1048 # traverse dependencies of
this module
1049 set (${MODULE}_CHECK_STARTED TRUE)
1050 foreach (D IN LISTS ${MODULE}_DEPENDS
1051 ${MODULE}_OPTIONAL_DEPENDS
1052 ${MODULE}_TOOLS_DEPENDS
1053 ${MODULE}_OPTIONAL_TOOLS_DEPENDS
1054 ${MODULE}_TEST_DEPENDS
1055 ${MODULE}_OPTIONAL_TEST_DEPENDS)
1056 basis_module_check (${D} ${MODULE}
"${MODULE};${STACK}")
1058 set (${MODULE}_CHECK_FINISHED TRUE)
1063 foreach (MODULE ${PROJECT_MODULES})
1064 basis_module_check (
"${MODULE}" "" "")
1067 # check if list of PROJECT_DEFAULT_MODULES contains invalid module name 1068 if (NOT
"^${PROJECT_DEFAULT_MODULES}$" STREQUAL
"^ALL$")
1069 foreach (MODULE IN LISTS PROJECT_DEFAULT_MODULES)
1070 list (FIND PROJECT_MODULES
"${MODULE}" IDX)
1072 message (FATAL_ERROR
"List of DEFAULT_MODULES specified in BasisProject.cmake file" 1073 " contains non-existing module ${MODULE}.")
1078 # -------------------------------------------------------------------------- 1079 # determine list of enabled modules 1081 # provide an option for all modules 1082 if (PROJECT_MODULES)
1086 # provide an option for each module 1087 foreach (MODULE ${PROJECT_MODULES})
1088 if (
"^${PROJECT_DEFAULT_MODULES}$" STREQUAL
"^ALL$")
1089 set (MODULE_${MODULE}_DEFAULT ON)
1091 list (FIND PROJECT_DEFAULT_MODULES
"${MODULE}" IDX)
1093 set (MODULE_${MODULE}_DEFAULT OFF)
1095 set (MODULE_${MODULE}_DEFAULT ON)
1098 if (${MODULE}_MISSING AND NOT MODULE_${MODULE}_DEFAULT)
1099 set (MODULE_${MODULE} NOTFOUND CACHE STRING
"Request to build the module ${MODULE}.")
1100 set_property (CACHE MODULE_${MODULE} PROPERTY STRINGS
"NOTFOUND;ON")
1102 option (MODULE_${MODULE}
"Request to build the module ${MODULE}." ${MODULE_${MODULE}_DEFAULT})
1103 set_property (CACHE MODULE_${MODULE} PROPERTY TYPE BOOL)
1105 unset (MODULE_${MODULE}_DEFAULT)
1108 # follow dependencies 1110 if (${MODULE}_DECLARED)
1111 if (NOT
"${NEEDED_BY}" STREQUAL
"")
1112 list (APPEND ${MODULE}_NEEDED_BY
"${NEEDED_BY}")
1114 if (NOT ${MODULE}_ENABLED)
1115 if (
"${NEEDED_BY}" STREQUAL
"")
1116 set (${MODULE}_NEEDED_BY)
1118 set (${MODULE}_ENABLED TRUE)
1119 foreach (D IN LISTS ${MODULE}_DEPENDS)
1122 if (BUILD_APPLICATIONS)
1123 foreach (D IN LISTS ${MODULE}_TOOLS_DEPENDS)
1128 foreach (D IN LISTS ${MODULE}_TEST_DEPENDS)
1136 foreach (MODULE ${PROJECT_MODULES})
1137 # EXCLUDE_<MODULE>_FROM_ALL can be
set on command-line via cmake -D
switch 1139 # EXCLUDE_<MODULE>_FROM_ALL
is set from the EXCLUDE_FROM_ALL
basis_project option.
1145 # build final list of enabled modules 1148 foreach (MODULE ${PROJECT_MODULES})
1149 if (${MODULE}_DECLARED)
1150 if (${MODULE}_ENABLED)
1160 # order list to satisfy dependencies 1161 include (${BASIS_MODULE_PATH}/TopologicalSort.cmake)
1162 foreach (MODULE ${PROJECT_MODULES})
1164 ${${MODULE}_DEPENDS}
1165 ${${MODULE}_OPTIONAL_DEPENDS}
1166 ${${MODULE}_TOOLS_DEPENDS}
1167 ${${MODULE}_OPTIONAL_TOOLS_DEPENDS}
1168 ${${MODULE}_TEST_DEPENDS}
1169 ${${MODULE}_OPTIONAL_TEST_DEPENDS}
1173 topological_sort (PROJECT_MODULES_SORTED "" "_USES
") 1174 foreach (MODULE ${PROJECT_MODULES}) 1175 unset (${MODULE}_USES) 1178 # remove disabled modules and external dependencies 1180 foreach (MODULE IN LISTS PROJECT_MODULES_SORTED) 1181 if (${MODULE}_DECLARED) 1182 list (FIND PROJECT_MODULES_ENABLED "${MODULE}
" IDX) 1183 if (NOT IDX EQUAL -1) 1184 list (APPEND L "${MODULE}
") 1188 set (PROJECT_MODULES_ENABLED "${L}
") 1191 # turn options ON for modules that are required by other modules 1192 foreach (MODULE ${PROJECT_MODULES}) 1193 if (DEFINED MODULE_${MODULE} # there was an option for the user 1194 AND NOT MODULE_${MODULE} # user did not set it to ON themself 1195 AND NOT ${MODULE}_IN_ALL # BUILD_ALL_MODULES was not set ON 1196 AND ${MODULE}_NEEDED_BY) # module is needed by other module(s) 1197 set (MODULE_${MODULE} ON CACHE BOOL "Request building module ${MODULE}.
" FORCE) 1198 message ("Enabled module ${MODULE}, needed by [${${MODULE}_NEEDED_BY}].
") 1202 # report what will be built 1203 if (PROJECT_MODULES_ENABLED) 1207 # check that all enabled external modules do exist 1208 foreach (MODULE IN LISTS PROJECT_EXTERNAL_MODULES) 1209 if (MODULE_${MODULE} AND ${MODULE}_MISSING) 1210 set (msg "External module ${MODULE}
is enabled but missing.
") 1211 if (EXISTS "${PROJECT_SOURCE_DIR}/.gitmodules
") 1212 set (msg "${
msg} If the module
is a Git submodule, ensure that it
" 1213 " is properly initialized, i.e.,\n
" 1214 "\tgit submodule update --init -- <module_dir>\n
") 1216 basis_list_to_string(msg ${msg}) 1217 message (FATAL_ERROR "${
msg}
") 1221 # undefine locally used variables 1234 # ---------------------------------------------------------------------------- 1235 ## @brief Check if named project module depends on the specified package 1237 # @param[out] result Name of boolean return variable. 1238 # @param[in] module Name of project module. 1239 # @param[in] package Name of (external) package. 1241 # @returns Sets @p result variable to either @c TRUE or @c FALSE. 1242 function (basis_check_if_module_depends_on_package result module package) 1244 cmake_parse_arguments(ARGN "REQUIRED;
OPTIONAL" "" "" ${ARGN}) 1245 if (ARGN_UNPARSED_ARGUMENTS) 1246 message(FATAL_ERROR "Too many arguments: ${ARGN_UNPARSED_ARGUMENTS}
") 1249 set(ARGN_REQUIRED TRUE) 1250 set(ARGN_OPTIONAL TRUE) 1252 basis_tokenize_dependency ("${package}
" pkg_name pkg_version pkg_comps) 1255 list(APPEND depends ${${module}_DEPENDS}) 1256 if (BUILD_APPLICATIONS) 1257 list(APPEND depends ${${module}_TOOLS_DEPENDS}) 1260 list(APPEND depends ${${module}_TEST_DEPENDS}) 1264 set(depends ${${module}_OPTIONAL_DEPENDS}) 1265 if (BUILD_APPLICATIONS) 1266 list(APPEND depends ${${module}_OPTIONAL_TOOLS_DEPENDS}) 1269 list(APPEND depends ${${module}_OPTIONAL_TEST_DEPENDS}) 1272 set(pkg_found FALSE) 1273 foreach (dep IN LISTS depends) 1274 basis_tokenize_dependency ("${dep}
" dep_name dep_version dep_comps) 1275 if ("^${dep_name}$
" STREQUAL "^${pkg_name}$
") 1277 foreach (comp IN LISTS pkg_comps) 1278 list(FIND dep_comps ${comp} idx) 1279 if (NOT idx EQUAL -1) 1293 set(${result} ${pkg_found} PARENT_SCOPE) 1296 # ---------------------------------------------------------------------------- 1297 ## @brief Check if any of the named/enabled modules depends on the specified package 1299 # @param[out] result Name of boolean return variable. 1300 # @param[in] package Name of (external) package. 1301 # @param[in] ARGN Names of project modules. If none specified, 1302 # the list of enabled modules is used instead. 1304 # @returns Sets @p result variable to either @c TRUE or @c FALSE. 1305 function (basis_check_if_package_is_needed_by_modules result package) 1307 set(modules ${ARGN}) 1309 set(modules ${PROJECT_MODULES_ENABLED}) 1311 set(pkg_found FALSE) 1312 foreach (module IN LISTS modules) 1313 basis_check_if_module_depends_on_package(pkg_found ${module} ${package}) 1318 set(${result} ${pkg_found} PARENT_SCOPE) 1321 # ---------------------------------------------------------------------------- 1322 ## @brief Configure public header files. 1323 function (basis_configure_public_headers) 1324 # -------------------------------------------------------------------------- 1327 # log file which lists the configured header files 1330 # ---------------------------------------------------------------------------- 1331 # header files to configure excluding the .in suffix 1343 # -------------------------------------------------------------------------- 1344 # clean up last run before the error because a file was added/removed 1345 file (REMOVE "${CMAKE_FILE}.tmp
") 1346 file (REMOVE "${CMAKE_FILE}.updated
") 1347 if (EXISTS "${CMAKE_FILE}
") 1348 # required to be able to remove now obsolete files from the build tree 1349 file (RENAME "${CMAKE_FILE}
" "${CMAKE_FILE}.tmp
") 1352 # -------------------------------------------------------------------------- 1353 # configure public header files 1354 message (STATUS "Configuring
public header files...
") 1356 if (NOT PROJECT_INCLUDE_DIRS) 1357 message (FATAL_ERROR "Missing argument PROJECT_INCLUDE_DIRS!
") 1360 # configure all .in files with substitution 1361 set (CONFIGURED_HEADERS) 1362 foreach (INCLUDE_DIR IN LISTS PROJECT_INCLUDE_DIRS) 1364 foreach (E IN LISTS EXTENSIONS) 1365 list (APPEND PATTERN "${INCLUDE_DIR}
string PROJECT
Project name.
function basis_get_relative_path(out REL, in BASE, in PATH)
Get path relative to a given base directory.
cmake PROJECT_DOCRES_DIR
Absolute path to directory of documentation ressource files in source tree.
cmake PROJECT_EXAMPLE_DIR
Absolute path to directory of example in source tree.
function is(in result, in expected, in name)
Test whether a given result is equal to the expected result.
cmake PROJECT_INCLUDE_DIRS
Absolute paths to directories of public header files in source tree.
cmake PROJECT_DOC_DIR
Absolute path to directory of documentation files in source tree.
function basis_get_module_info(in MODULE_NAME, in F, in ARGN)
cmake PROJECT_MODULES_DIR
Absolute path to directory containing project modules in subdirectories.
cmake PROJECT_LIBRARY_DIR
Absolute path to directory of public scripted packages.
cmake PROJECT_DATA_DIR
Absolute path to directory of auxiliary data in source tree.
cmake BINARY_INCLUDE_DIR
Absolute path to output directory for configured public header files.
option BUILD_TESTING
Request build of tests.
cmake PROJECT_MODULE_DIRS
Absolute paths to root directories of project modules.
macro basis_sanitize_for_regex(out OUT, in STR)
Sanitize string variable for use in regular expression.
macro basis_set_if_empty(out VAR, in ARGN)
Set value of variable only if variable is not set already.
macro basis_module_enable(in MODULE, in NEEDED_BY)
function basis_installtree_asserts(in ARGN)
Ensure certain requirements on install tree.
cmake PROJECT_MODULES_ENABLED
function basis_buildtree_asserts(in ARGN)
Ensure certain requirements on build tree.
cmake PROJECT_CONFIG_DIR
Absolute path to directory of BASIS project configuration in source tree.
function basis_list_to_string(out STR, in ARGN)
Concatenates all list elements into a single string.
macro basis_project_modules()
Initialize project modules.
macro basis_add_module_info(in MODULE_NAME, in F)
Manually add project module to list of modules.
macro basis_find_package(in PACKAGE, in ARGN)
Find external software package or other project module.
cmake PROJECT_MODULES_SORTED
macro basis_project(in ARGN)
Sets basic project information including the name, version, and dependencies.
cmake PROJECT_CODE_DIRS
Absolute paths to directories of project sources in source tree.
cmake PROJECT_TESTING_DIR
Absolute path to directory of testing tree in source tree.
cmake PROJECT_SUBDIRS
Names of additional project subdirectories at root level.
cmake PROJECT_MODULES_DISABLED
function basis_tokenize_dependency(in DEP, out PKG, out VER, out CMP)
Tokenize dependency specification.
macro basis_find_packages()
Find packages this project depends on.
function get_filename_component(inout ARGN)
Fixes CMake's get_filename_component() command.