BasisConfigSettings.cmake
Go to the documentation of this file.
1 # ============================================================================
2 # Copyright (c) 2011-2012 University of Pennsylvania
3 # Copyright (c) 2013-2016 Andreas Schuh
4 # All rights reserved.
5 #
6 # See COPYING file for license information or visit
7 # https://cmake-basis.github.io/download.html#license
8 # ============================================================================
9 
10 ##############################################################################
11 # @file BasisConfigSettings.cmake
12 # @brief Sets basic variables used in CMake package configuration.
13 #
14 # It is suggested to use @c _CONFIG as suffix for variable names that are to be
15 # substituted in the Config.cmake.in template file in order to distinguish
16 # these variables from the build configuration.
17 #
18 # @ingroup BasisSettings
19 ##############################################################################
20 
21 # ============================================================================
22 # common configuration settings
23 # ============================================================================
24 
25 ## @brief Include directories of dependencies.
26 set (INCLUDE_DIRS_CONFIG)
27 ## @brief Directories of libraries this package depends on.
28 set (LIBRARY_DIRS_CONFIG)
29 
30 ## @brief Code to set cached <Pkg>_DIR variables in package configuration.
31 set (DEPENDS_CONFIG)
32 
33 set (PKGS)
34 foreach (DEP IN LISTS PROJECT_DEPENDS PROJECT_OPTIONAL_DEPENDS)
35  basis_tokenize_dependency ("${DEP}" PKG VER CMPS)
36  if (DEPENDS_${PKG}_DIR)
37  list (APPEND PKGS ${PKG})
38  endif ()
39 endforeach ()
40 
41 if (PKGS)
42  list (REMOVE_DUPLICATES PKGS)
43 endif ()
44 
45 if (PKGS)
46  set (DEPENDS_CONFIG "set (_depwarn \" set to different value than during the configuration of ${PROJECT_NAME}.\""
47  " \" Using different versions of a dependency may cause inconsistencies!\")")
48 endif ()
49 foreach (PKG IN LISTS PKGS)
50  list (APPEND DEPENDS_CONFIG
51  "# ${PKG}"
52  "if (DEPENDS_${PKG}_DIR)"
53  " if (NOT DEPENDS_${PKG}_DIR STREQUAL \"${DEPENDS_${PKG}_DIR}\")"
54  " message (WARNING DEPENDS_${PKG}_DIR \${_depwarn})"
55  " endif ()"
56  "else ()"
57  " basis_set_or_update_value (DEPENDS_${PKG}_DIR \"${DEPENDS_${PKG}_DIR}\")"
58  "endif ()"
59  )
60 endforeach ()
61 if (PKGS)
62  list (APPEND DEPENDS_CONFIG "unset (_depwarn)")
63 endif ()
64 basis_join ("${DEPENDS_CONFIG}" "\n" DEPENDS_CONFIG)
65 
66 # ============================================================================
67 # build tree configuration settings
68 # ============================================================================
69 
71  set (INSTALL_PREFIX_CONFIG "${PROJECT_BINARY_DIR}")
72  if (BUILD_EXAMPLE)
73  set (EXAMPLE_DIR_CONFIG "${PROJECT_EXAMPLE_DIR}")
74  else ()
75  set (EXAMPLE_DIR_CONFIG)
76  endif ()
77  set (INCLUDE_DIR_CONFIG "${BINARY_INCLUDE_DIR};${PROJECT_INCLUDE_DIR}")
78  set (LIBRARY_DIR_CONFIG "${BINARY_LIBRARY_DIR}")
79  set (PYTHONPATH_CONFIG "${BINARY_PYTHON_LIBRARY_DIR}")
80  set (JYTHONPATH_CONFIG "${BINARY_JYTHON_LIBRARY_DIR}")
81  set (PERL5LIB_CONFIG "${BINARY_PERL_LIBRARY_DIR}")
82  set (MATLABPATH_CONFIG "${BINARY_MATLAB_LIBRARY_DIR}")
83  set (BASHPATH_CONFIG "${BINARY_BASH_LIBRARY_DIR}")
84  set (MODULES_DIR_CONFIG "${BINARY_LIBCONF_DIR}")
85  return ()
86 endif ()
87 
88 # ============================================================================
89 # installation configuration settings
90 # ============================================================================
91 
92 basis_get_relative_path (INSTALL_PREFIX_CONFIG "${CMAKE_INSTALL_PREFIX}/${INSTALL_CONFIG_DIR}" "${CMAKE_INSTALL_PREFIX}")
93 
94 ## @brief Installation prefix.
95 set (INSTALL_PREFIX_CONFIG "\${CMAKE_CURRENT_LIST_DIR}/${INSTALL_PREFIX_CONFIG}")
96 ## @brief Directory of example files.
97 if (BUILD_EXAMPLE)
98  set (EXAMPLE_DIR_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_EXAMPLE_DIR}")
99 else ()
100  set (EXAMPLE_DIR_CONFIG)
101 endif ()
102 ## @brief Include directories.
103 set (INCLUDE_DIR_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
104 ## @brief Directory where libraries are located.
105 set (LIBRARY_DIR_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_LIBRARY_DIR}")
106 ## @brief Directory of Python modules.
107 set (PYTHONPATH_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_PYTHON_LIBRARY_DIR}")
108 ## @brief Directory of Jython modules.
109 set (JYTHONPATH_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_JYTHON_LIBRARY_DIR}")
110 ## @brief Directory of Perl modules.
111 set (PERL5LIB_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_PERL_LIBRARY_DIR}")
112 ## @brief Directory of MATLAB modules.
113 set (MATLABPATH_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_MATLAB_LIBRARY_DIR}")
114 ## @brief Directory of Bash modules.
115 set (BASHPATH_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_BASH_LIBRARY_DIR}")
116 ## @brief Directory of CMake package configuration files of project modules.
117 set (MODULES_DIR_CONFIG "\${\${NS}INSTALL_PREFIX}/${INSTALL_CONFIG_DIR}")
cmake PERL5LIB_CONFIG
Directory of Perl modules.
function basis_get_relative_path(out REL, in BASE, in PATH)
Get path relative to a given base directory.
cmake MATLABPATH_CONFIG
Directory of MATLAB modules.
cmake BASHPATH_CONFIG
Directory of Bash modules.
cmake PYTHONPATH_CONFIG
Directory of Python modules.
cmake LIBRARY_DIR_CONFIG
Directory where libraries are located.
option BUILD_EXAMPLE
Request build/installation of example.
cmake BUILD_CONFIG_SETTINGS
cmake INSTALL_PREFIX_CONFIG
Installation prefix.
cmake MODULES_DIR_CONFIG
Directory of CMake package configuration files of project modules.
function basis_join(in VALUES, in DELIMITER, out OUTPUT)
Concatenates all list elements into a single delimited string.
cmake EXAMPLE_DIR_CONFIG
Directory of example files.
cmake JYTHONPATH_CONFIG
Directory of Jython modules.
cmake INCLUDE_DIR_CONFIG
Include directories.
function basis_tokenize_dependency(in DEP, out PKG, out VER, out CMP)
Tokenize dependency specification.