1 # ============================================================================ 2 # Copyright (c) 2011-2012 University of Pennsylvania 3 # Copyright (c) 2013-2016 Andreas Schuh 6 # See COPYING file for license information or visit 7 # https://cmake-basis.github.io/download.html#license 8 # ============================================================================ 10 ############################################################################## 11 # @file DirectoriesSettings.cmake 12 # @brief CMake variables of project directories. 14 # This file configures the project directory structure as defined by the 15 # Filesystem Hierarchy Standard for BASIS packages. 17 # @sa https://cmake-basis.github.io/standard/fhs/ 19 # The project must follow the directory structure as defined by the 20 # <tt>PROJECT_<*>_DIR</tt> variables. 22 # Ideally, when changing the name of one of these directories, only the 23 # directory structure of the template needs to be updated. The BASIS CMake 24 # functions should not be required to change as they are supposed to use these 25 # variables instead of the actual names. Any change of the project directory 26 # structure has to be made with care, however, and backwards compatibility to 27 # previous releases of BASIS shall be maintained. Consider the use of the 28 # @c TEMPLATE_VERSION if required. 30 # @note The documentation of the variables can be found in Directories.cmake.in. 31 ############################################################################## 34 # ============================================================================ 35 # root directories of top-level project 36 # ============================================================================ 38 if (NOT PROJECT_IS_MODULE)
43 # ============================================================================ 45 # ============================================================================ 47 if (BUNDLE_NAME AND NOT BUNDLE_NAME MATCHES
"${PROJECT_PACKAGE_NAME_RE}")
52 if (PROJECT_PACKAGE_VENDOR)
53 set (
_VENDOR "/${PROJECT_PACKAGE_VENDOR}")
58 if (PROJECT_IS_SUBPROJECT)
64 string (TOLOWER
"${_VENDOR}" _VENDOR)
65 string (TOLOWER
"${_PACKAGE}" _PACKAGE)
66 string (TOLOWER
"${_MODULE}" _MODULE)
67 string (TOLOWER
"${_BUNDLE}" _BUNDLE)
70 # ============================================================================ 71 # directories of site packages of script interpreters 72 # ============================================================================ 74 # ---------------------------------------------------------------------------- 76 if (PYTHON_EXECUTABLE)
78 COMMAND "${PYTHON_EXECUTABLE}" "${BASIS_MODULE_PATH}/get_python_lib.py" 81 OUTPUT_STRIP_TRAILING_WHITESPACE
88 # ---------------------------------------------------------------------------- 90 if (JYTHON_EXECUTABLE)
92 COMMAND "${JYTHON_EXECUTABLE}" "${BASIS_MODULE_PATH}/get_python_lib.py" 95 OUTPUT_STRIP_TRAILING_WHITESPACE
102 # ---------------------------------------------------------------------------- 109 # ============================================================================ 111 # ============================================================================ 119 foreach (_L IN ITEMS python jython perl matlab bash)
120 string (TOUPPER
"${_L}" _U)
121 set (TESTING_${_U}_LIBRARY_DIR
"${TOPLEVEL_PROJECT_BINARY_DIR}/Testing/lib/${_L}")
124 # ============================================================================ 126 # ============================================================================ 128 # set directories corresponding to the source tree directories 129 foreach (
_P CODE CONFIG DATA DOC EXAMPLE MODULES TESTING)
131 set (BINARY_${
_P}_DIR
"${PROJECT_BINARY_DIR}/${_D}")
146 foreach (_L IN ITEMS python jython perl matlab bash)
147 string (TOUPPER
"${_L}" _U)
148 set (BINARY_${_U}_LIBRARY_DIR
"${TOPLEVEL_PROJECT_BINARY_DIR}/lib/${_L}")
151 # set default CMake variables which are, however, not used by BASIS 156 # ============================================================================
158 # ============================================================================
160 # Attention: In order
for CPack to work correctly, the destination paths have
162 # prefix must be excluded from the following paths!
164 # ----------------------------------------------------------------------------
165 #
default installation prefix
167 # change default installation prefix used by CMake 168 if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
169 # <ProgramFilesDir>/<Vendor>/<Package>[-<version>] 171 get_filename_component (CMAKE_INSTALL_PREFIX
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion;ProgramFilesDir]" ABSOLUTE)
172 if (NOT CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX MATCHES
"/registry")
173 set (CMAKE_INSTALL_PREFIX
"C:/Program Files")
175 set (CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}${_VENDOR}${_PACKAGE}")
176 if (NOT PROJECT_VERSION MATCHES
"^0\\.0\\.0$")
177 set (CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}-${PROJECT_VERSION}")
179 # /opt/<vendor>/<package>[-<version>] 181 set (CMAKE_INSTALL_PREFIX
"/opt${_VENDOR}${_PACKAGE}")
182 if (NOT PROJECT_VERSION MATCHES
"^0\\.0\\.0$")
183 set (CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}-${PROJECT_VERSION}")
187 set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}
" CACHE PATH "Installation prefix.
" FORCE) 189 # ---------------------------------------------------------------------------- 190 # installation scheme - non-cached, can be preset using -D option of CMake 191 set (BASIS_INSTALL_SCHEME "default
" CACHE STRING "default, opt, usr, win
") 192 set_property(CACHE BASIS_INSTALL_SCHEME PROPERTY STRINGS default opt usr win) 193 mark_as_advanced (BASIS_INSTALL_SCHEME) 195 if (BASIS_INSTALL_SCHEME MATCHES "default") 196 string (TOLOWER "${CMAKE_INSTALL_PREFIX}
" _CMAKE_INSTALL_PREFIX_L) 197 basis_sanitize_for_regex (_BUNDLE_NAME_RE "${BUNDLE_NAME}
") 198 string (TOLOWER "{_BUNDLE_NAME_RE}
" _BUNDLE_NAME_RE_L) 199 string (TOUPPER "{_BUNDLE_NAME_RE}
" _BUNDLE_NAME_RE_U) 201 set (BASIS_INSTALL_SCHEME win) 202 elseif (NOT _BUNDLE AND _CMAKE_INSTALL_PREFIX_L MATCHES "/(.*[_-])?(${PROJECT_PACKAGE_NAME_RE}|${PROJECT_PACKAGE_NAME_RE_L}|${PROJECT_PACKAGE_NAME_RE_U})[_-]?
") # e.g. /opt/<package>[-<version>] 203 set (BASIS_INSTALL_SCHEME opt) 204 elseif (_BUNDLE AND _CMAKE_INSTALL_PREFIX_L MATCHES "/(.*[_-])?(${_BUNDLE_NAME_RE}|${_BUNDLE_NAME_RE_L}|${_BUNDLE_NAME_RE_U})[_-]?
") # e.g. /opt/<bundle>[-<version>] 205 set (BASIS_INSTALL_SCHEME opt) 207 set (BASIS_INSTALL_SCHEME usr) 209 unset (_CMAKE_INSTALL_PREFIX_L) 210 unset (_BUNDLE_NAME_RE) 211 unset (_BUNDLE_NAME_RE_L) 212 unset (_BUNDLE_NAME_RE_U) 215 if (NOT BASIS_INSTALL_SCHEME MATCHES "^(opt|usr|win|bundle)$
") 216 message (FATAL_ERROR "Invalid
BASIS_INSTALL_SCHEME! Valid values are
'default',
'opt',
'usr',
'win'.
") 219 # ---------------------------------------------------------------------------- 220 # installation directories 221 if (BASIS_INSTALL_SCHEME MATCHES "win
") # e.g., CMAKE_INSTALL_PREFIX := <ProgramFilesDir>/<Vendor>/<Package> 223 # -------------------------------------------------------------------------- 226 # package configuration 227 set (INSTALL_CONFIG_DIR "CMake
") 232 set (INSTALL_INCLUDE_DIR "Include
") 241 set (INSTALL_MAN_DIR) 242 set (INSTALL_TEXINFO_DIR) 243 # -------------------------------------------------------------------------- 246 # package configuration 247 set (INSTALL_CONFIG_DIR "CMake
") 249 set (INSTALL_RUNTIME_DIR "Bin
") 250 set (INSTALL_LIBEXEC_DIR "Lib${
_MODULE}
") 252 set (INSTALL_INCLUDE_DIR "Include
") 253 set (INSTALL_LIBRARY_DIR "Lib${
_MODULE}
") 254 set (INSTALL_ARCHIVE_DIR "Lib${
_MODULE}
") 256 set (INSTALL_SHARE_DIR "Share${
_MODULE}
") 257 set (INSTALL_DATA_DIR "Data${
_MODULE}
") 258 set (INSTALL_EXAMPLE_DIR "Example${
_MODULE}
") 260 set (INSTALL_DOC_DIR "Doc${
_MODULE}
") 261 set (INSTALL_MAN_DIR) 262 set (INSTALL_TEXINFO_DIR) 265 elseif (BASIS_INSTALL_SCHEME MATCHES "usr
") # e.g., CMAKE_INSTALL_PREFIX := /usr/local 267 # -------------------------------------------------------------------------- 270 # package configuration 271 set (INSTALL_CONFIG_DIR "lib/cmake${
_BUNDLE}
") 276 set (INSTALL_INCLUDE_DIR "include
") 287 # -------------------------------------------------------------------------- 290 # package configuration 291 set (INSTALL_CONFIG_DIR "lib/cmake${
_PACKAGE}
") 293 set (INSTALL_RUNTIME_DIR "bin
") 296 set (INSTALL_INCLUDE_DIR "include
") 305 set (INSTALL_MAN_DIR "share/man
") 306 set (INSTALL_TEXINFO_DIR "share/info
") 309 else () # e.g., CMAKE_INSTALL_PREFIX := /opt/<vendor>/<package> 311 # -------------------------------------------------------------------------- 314 # package configuration 315 set (INSTALL_CONFIG_DIR "lib/cmake${
_BUNDLE}
") 320 set (INSTALL_INCLUDE_DIR "include
") 332 # package configuration 333 set (INSTALL_CONFIG_DIR "lib/cmake${
_PACKAGE}
") 335 set (INSTALL_RUNTIME_DIR "bin
") 336 set (INSTALL_LIBEXEC_DIR "lib${
_MODULE}
") 338 set (INSTALL_INCLUDE_DIR "include
") 339 set (INSTALL_LIBRARY_DIR "lib${
_MODULE}
") 340 set (INSTALL_ARCHIVE_DIR "lib${
_MODULE}
") 342 set (INSTALL_SHARE_DIR "share${
_MODULE}
") 343 set (INSTALL_DATA_DIR "share${
_MODULE}/data
") 344 set (INSTALL_EXAMPLE_DIR "share${
_MODULE}/example
") 346 set (INSTALL_DOC_DIR "doc${
_MODULE}
") 347 set (INSTALL_MAN_DIR "man
") 348 set (INSTALL_TEXINFO_DIR "info
") 353 # ---------------------------------------------------------------------------- 354 # private script libraries 356 # The modules of script libraries which are only intended for use by this 357 # package itself are installed within the package own installation 358 # prefix/subdirectories. 359 if (BASIS_INSTALL_SCHEME MATCHES "win
") 361 foreach (_L IN ITEMS Python Jython Perl Matlab Bash) 362 string (TOUPPER "${_L}
" _U) 363 if (BASIS_COMPILE_SCRIPTS) 364 if (_U MATCHES "PERL
") 365 set (INSTALL_${_U}_LIBRARY_DIR "Lib/Perl5
") 366 elseif (NOT _U MATCHES "MATLAB|BASH
" AND ${_U}_VERSION_MAJOR AND DEFINED ${_U}_VERSION_MINOR) 367 set (INSTALL_${_U}_LIBRARY_DIR "Lib/${_L}${${_U}_VERSION_MAJOR}.${${_U}_VERSION_MINOR}
") 369 set (INSTALL_${_U}_LIBRARY_DIR "Lib/${_L}
") 372 set (INSTALL_${_U}_LIBRARY_DIR "Lib/${_L}
") 376 elseif (BASIS_INSTALL_SCHEME MATCHES "usr
") 384 foreach (_L IN ITEMS python jython perl matlab bash) 385 string (TOUPPER "${_L}
" _U) 386 if (BASIS_COMPILE_SCRIPTS) 387 if (_U MATCHES "PERL
") 388 set (INSTALL_${_U}_LIBRARY_DIR "lib${
_P}/perl5
") 389 elseif (NOT _U MATCHES "MATLAB|BASH
" AND ${_U}_VERSION_MAJOR AND DEFINED ${_U}_VERSION_MINOR) 390 set (INSTALL_${_U}_LIBRARY_DIR "lib${
_P}/${_L}${${_U}_VERSION_MAJOR}.${${_U}_VERSION_MINOR}
") 392 set (INSTALL_${_U}_LIBRARY_DIR "lib${
_P}/${_L}
") 395 set (INSTALL_${_U}_LIBRARY_DIR "lib${
_P}/${_L}
") 401 foreach (_L IN ITEMS python jython perl matlab bash) 402 string (TOUPPER "${_L}
" _U) 403 if (BASIS_COMPILE_SCRIPTS) 404 if (_U MATCHES "PERL
") 405 set (INSTALL_${_U}_LIBRARY_DIR "lib/perl5
") 406 elseif (NOT _U MATCHES "MATLAB|BASH
" AND ${_U}_VERSION_MAJOR AND DEFINED ${_U}_VERSION_MINOR) 407 set (INSTALL_${_U}_LIBRARY_DIR "lib/${_L}${${_U}_VERSION_MAJOR}.${${_U}_VERSION_MINOR}
") 409 set (INSTALL_${_U}_LIBRARY_DIR "lib/${_L}
") 412 set (INSTALL_${_U}_LIBRARY_DIR "lib/${_L}
") 418 # ---------------------------------------------------------------------------- 419 # public script libraries 421 # The modules of script libraries which are intended for use by external packages 422 # are installed in the respective installation directories of the particular 423 # interpreter. For example, in case of Python, the public Python modules are 424 # installed in the site-packages directory of the found PYTHON_EXECUTABLE. 425 # In particular the modules in the PROJECT_LIBRARY_DIR are intended for use 426 # by external packages. Other modules added using the basis_add_script_library() 427 # and basis_add_script() CMake functions are by default considered to be intended 428 # for internal use by the other modules and executable scripts. 430 # Note: For those interpreters of scripting languages which by themselves do 431 # not define a common installation directory for site packages, the 432 # installation directory for public modules may be identical to the 433 # one for private modules. Moreover, the user has the option to disable 434 # the installation of public modules in the system default site directories 435 # in order to prevent the installation of files outside the CMAKE_INSTALL_PREFIX. 437 # reset directories if BASIS_INSTALL_SITE_PACKAGES option has been changed 438 if (DEFINED _BASIS_INSTALL_SITE_PACKAGES) 440 if (BASIS_INSTALL_SITE_PACKAGES AND NOT _BASIS_INSTALL_SITE_PACKAGES) 442 elseif (NOT BASIS_INSTALL_SITE_PACKAGES AND _BASIS_INSTALL_SITE_PACKAGES) 446 foreach (_L IN ITEMS PYTHON JYTHON PERL) 447 # do not reset if BASIS_INSTALL_SITE_PACKAGES is OFF and path is already relative 448 if (IS_ABSOLUTE "${INSTALL_${_L}_SITE_DIR}
" OR BASIS_INSTALL_SITE_PACKAGES) 449 basis_update_value (INSTALL_${_L}_SITE_DIR) 457 # try to determine default installation directories 458 if (BASIS_INSTALL_SITE_PACKAGES) 460 if (NOT INSTALL_PYTHON_SITE_DIR) 464 if (NOT INSTALL_JYTHON_SITE_DIR) 468 if (NOT INSTALL_PERL_SITE_DIR) 473 # if it failed to determine the default installation directories by executing some 474 # code or command, use the directories used for private libraries instead 475 foreach (_U IN ITEMS PYTHON JYTHON PERL MATLAB BASH) 476 if (NOT INSTALL_${_U}_SITE_DIR) 477 set (INSTALL_${_U}_SITE_DIR "${INSTALL_${_U}_LIBRARY_DIR}
") 481 # cache directories - also so users can edit them 482 foreach (_L IN ITEMS Python Jython Perl MATLAB Bash) 483 string (TOUPPER "${_L}
" _U) 484 set (INSTALL_${_U}_SITE_DIR "${INSTALL_${_U}_SITE_DIR}
" CACHE PATH "Installation directory
for public ${_L} modules.
" FORCE) 485 mark_as_advanced (INSTALL_${_U}_SITE_DIR) 488 # ============================================================================ 489 # top-level references 490 # ============================================================================ 492 if (NOT PROJECT_IS_MODULE) 494 foreach (_D CODE CONFIG DATA DOC EXAMPLE INCLUDE MODULES TESTING) 495 set (TOPLEVEL_PROJECT_${_D}_DIR "${PROJECT_${_D}_DIR}
") 498 foreach (_D CODE CONFIG DATA DOC EXAMPLE INCLUDE MODULES TESTING RUNTIME LIBEXEC LIBRARY ARCHIVE LIBCONF) 499 set (TOPLEVEL_BINARY_${_D}_DIR "${BINARY_${_D}_DIR}
") 501 foreach (_L IN ITEMS PYTHON JYTHON PERL MATLAB BASH) 502 set (TOPLEVEL_BINARY_${_L}_LIBRARY_DIR "${BINARY_${_L}_LIBRARY_DIR}
") 505 foreach (_D IN ITEMS CONFIG INCLUDE RUNTIME LIBEXEC LIBRARY ARCHIVE DATA DOC EXAMPLE SHARE) 506 set (TOPLEVEL_INSTALL_${_D}_DIR "${INSTALL_${_D}_DIR}
") 508 foreach (_L IN ITEMS PYTHON JYTHON PERL MATLAB BASH) 509 set (TOPLEVEL_INSTALL_${_L}_LIBRARY_DIR "${INSTALL_${_L}_LIBRARY_DIR}
") 513 # ============================================================================ 515 # ============================================================================ 525 unset (_DEFAULT_SCHEME) 529 # end of Doxygen group
cmake TESTING_LIBEXEC_DIR
cmake PERL_SITELIB
Default directory for Perl site packages.
function basis_get_relative_path(out REL, in BASE, in PATH)
Get path relative to a given base directory.
cmake CMAKE_RUNTIME_OUTPUT_DIRECTORY
option BASIS_INSTALL_SITE_PACKAGES
Enable the installation of scripted modules in site specific default directories. ...
cmake BASIS_INSTALL_SCHEME
cmake CMAKE_LIBRARY_OUTPUT_DIRECTORY
cmake TOPLEVEL_PROJECT_SOURCE_DIR
cmake PYTHON_SITELIB
Default directory for Python site packages.
cmake TESTING_RUNTIME_DIR
cmake JYTHON_SITELIB
Default directory for Jython site packages.
cmake TESTING_ARCHIVE_DIR
cmake TESTING_LIBRARY_DIR
cmake CMAKE_INSTALL_PREFIX
#define UNIX
Whether the sources are compiled on a Unix-based system.
cmake CMAKE_ARCHIVE_OUTPUT_DIRECTORY
cmake TOPLEVEL_PROJECT_BINARY_DIR
macro find_package()
Overloaded find_package() command.
function get_filename_component(inout ARGN)
Fixes CMake's get_filename_component() command.