BASISConfig.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 BASISConfig.cmake
12 # @brief CMake package configuration file.
13 #
14 # @note The BASISConfig.cmake file is automatically generated
15 # by BASIS from the template file Config.cmake.in which is part of
16 # the BASIS package.
17 #
18 # Variables in this file have to be prefixed by the name of this package.
19 # In the default package configuration file of BASIS, which can be included
20 # here using the \@BASIS_CONFIG\@ variable, this prefix is defined as @c NS
21 # variable. Moreover, the macro basis_set_config() should be used for
22 # convenience to set any configuration variable, e.g.,
23 #
24 # @code
25 # basis_set_config (INCLUDE_DIR "\@INCLUDE_DIR_CONFIG\@")
26 # @endcode
27 #
28 # where the variable @c INCLUDE_DIR_CONFIG is set in the ConfigSettings.cmake
29 # file of the BASIS installation. Note that this statement will set the
30 # variable ${NS}INCLUDE_DIR, where by default @c NS is the package name
31 # followed by an underscore (_).
32 #
33 # See the Config.cmake.in file of BASIS for details.
34 #
35 # @ingroup BasisConfig
36 ##############################################################################
37 
38 ## @addtogroup BasisConfig
39 # @{
40 
41 
42 # ============================================================================
43 # namespace
44 # ============================================================================
45 
46 # prefix used for variable names
47 set (NS "BASIS_")
48 
49 # allow caller to change namespace - used by projects with modules
50 if (${NS}CONFIG_PREFIX)
51  set (NS "${${NS}CONFIG_PREFIX}_")
52 endif ()
53 
54 # ----------------------------------------------------------------------------
55 macro (basis_set_config NAME)
56  set (${NS}${NAME} ${ARGN})
57 endmacro ()
58 
59 # ----------------------------------------------------------------------------
60 macro (basis_copy_config NAME SRC)
61  set (${NS}${NAME} ${${NS}${SRC}})
62 endmacro ()
63 
64 # ----------------------------------------------------------------------------
65 macro (basis_append_config NAME)
66  list (APPEND ${NS}${NAME} ${ARGN})
67 endmacro ()
68 
69 # ----------------------------------------------------------------------------
70 macro (basis_find_config NAME VALUE IDX)
71  list (FIND ${NS}${NAME} "${VALUE}" ${IDX})
72 endmacro ()
73 
74 # ----------------------------------------------------------------------------
76  if (${NS}${NAME})
77  list (REMOVE_DUPLICATES ${NS}${NAME})
78  endif ()
79 endmacro ()
80 
81 # ----------------------------------------------------------------------------
82 macro (basis_remove_item_config NAME ITEM)
83  if (${NS}${NAME})
84  list (REMOVE_ITEM ${NS}${NAME} "${ITEM}")
85  endif ()
86 endmacro ()
87 
88 # ----------------------------------------------------------------------------
89 if (NOT COMMAND basis_is_cached)
90  macro (basis_is_cached VAR ENTRY)
91  if (DEFINED ${ENTRY})
92  get_property (${VAR} CACHE ${ENTRY} PROPERTY TYPE SET)
93  else ()
94  set (${VAR} FALSE)
95  endif ()
96  endmacro ()
97 endif ()
98 
99 # ----------------------------------------------------------------------------
101  macro (basis_set_or_update_value VAR)
102  basis_is_cached (_CACHED ${VAR})
103  if (_CACHED)
104  if (${ARGC} GREATER 1)
105  set_property (CACHE ${VAR} PROPERTY VALUE ${ARGN})
106  else ()
107  set (${VAR} "" CACHE INTERNAL "" FORCE)
108  endif ()
109  else ()
110  set (${VAR} ${ARGN})
111  endif ()
112  unset (_CACHED)
113  endmacro ()
114 endif ()
115 
116 # ============================================================================
117 # general
118 # ============================================================================
119 
120 ## @brief Installation prefix or root of build tree.
121 basis_set_config (INSTALL_PREFIX "/Users/as12312/Software/BASIS/Xcode")
122 get_filename_component (${NS}INSTALL_PREFIX "${${NS}INSTALL_PREFIX}" ABSOLUTE)
123 
124 ## @brief Project use file to be included by other projects.
125 basis_set_config (USE_FILE "${CMAKE_CURRENT_LIST_DIR}/BASISUse.cmake")
126 
127 ## @brief Directory of example files.
128 basis_set_config (EXAMPLE_DIR "/Users/as12312/Software/BASIS/Workspace/example")
129 
130 # ============================================================================
131 # libraries
132 # ============================================================================
133 
134 ## @brief Directory of header files.
135 basis_set_config (INCLUDE_DIR "/Users/as12312/Software/BASIS/Xcode/include;/Users/as12312/Software/BASIS/Workspace/include")
136 
137 ## @brief Directory of header files including dependencies.
138 basis_set_config (INCLUDE_DIRS) # to have a set recognized by Doxygen filter
139 basis_copy_config (INCLUDE_DIRS INCLUDE_DIR)
140 basis_append_config (INCLUDE_DIRS "")
141 
142 ## @brief Directory of libraries.
143 basis_set_config (LIBRARY_DIR "/Users/as12312/Software/BASIS/Xcode/lib")
144 
145 ## @brief Directory of libraries including dependencies.
146 basis_set_config (LIBRARY_DIRS) # to have a set() recognized by Doxygen filter
147 basis_copy_config (LIBRARY_DIRS LIBRARY_DIR)
148 basis_append_config (LIBRARY_DIRS "")
149 
150 ## @brief Search path for Python modules.
151 basis_set_config (PYTHONPATH "/Users/as12312/Software/BASIS/Xcode/lib/python")
152 
153 ## @brief Search path for Jython modules.
154 basis_set_config (JYTHONPATH "/Users/as12312/Software/BASIS/Xcode/lib/jython")
155 
156 ## @brief Search path for Perl modules.
157 basis_set_config (PERL5LIB "/Users/as12312/Software/BASIS/Xcode/lib/perl")
158 
159 ## @brief Search path for MATLAB modules.
160 basis_set_config (MATLABPATH "/Users/as12312/Software/BASIS/Xcode/lib/matlab")
161 
162 ## @brief Search path for Bash modules.
163 #
164 # See the import() function of the BASIS Bash utilities.
165 basis_set_config (BASHPATH "/Users/as12312/Software/BASIS/Xcode/lib/bash")
166 
167 # ============================================================================
168 # exports
169 # ============================================================================
170 
171 ## @brief Absolute path of exports file to be included by other projects.
172 basis_set_config (EXPORTS_FILE "${CMAKE_CURRENT_LIST_DIR}/BASISExports.cmake")
173 
174 ## @brief Absolute path of custom exports file to be included by other projects.
175 basis_set_config (CUSTOM_EXPORTS_FILE "${CMAKE_CURRENT_LIST_DIR}/BASISCustomExports.cmake")
176 
177 # ============================================================================
178 # modules
179 # ============================================================================
180 
181 ## @brief Directory containing module configuration files
182 basis_set_config (MODULES_DIR "/Users/as12312/Software/BASIS/Xcode/lib/cmake/basis")
183 
184 ## @brief List of known project modules.
185 basis_set_config (MODULES "")
186 
187 ## @brief List of found requested modules.
188 basis_set_config (MODULES_FOUND)
189 
190 ## @brief List of not found optional modules.
191 basis_set_config (MODULES_NOTFOUND)
192 
193 ## @brief List of available project modules.
194 basis_set_config (MODULES_ENABLED)
195 file (GLOB _CONFIG_FILES "${${NS}MODULES_DIR}/BASIS*Config.cmake")
196 foreach (_CONFIG_FILE IN LISTS _CONFIG_FILES)
197  if (_CONFIG_FILE MATCHES "/BASIS([^ /][^ /]*)Config.cmake")
198  set (_MODULE_NAME ${CMAKE_MATCH_1})
199  basis_append_config (MODULES ${_MODULE_NAME})
200  basis_append_config (MODULES_ENABLED ${_MODULE_NAME})
201  endif ()
202 endforeach ()
203 
204 basis_remove_duplicates_config (MODULES)
205 basis_remove_duplicates_config (MODULES_ENABLED)
206 
207 unset (_CONFIG_FILES)
208 unset (_CONFIG_FILE)
209 
210 ## @brief List of modules requested by external package using the
211 # @c COMPONENTS argument of
212 # <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package">
213 # find_package()</a>.
214 if (NOT DEFINED ${NS}MODULES_REQUESTED)
215  if (${NS}FIND_COMPONENTS)
216  basis_copy_config (MODULES_REQUESTED FIND_COMPONENTS)
217  endif ()
218  if (NOT ${NS}MODULES_REQUESTED)
219  basis_copy_config (MODULES_REQUESTED MODULES_ENABLED)
220  endif ()
221 endif ()
222 basis_remove_duplicates_config (MODULES_REQUESTED)
223 
224 set (_PACKAGE_NS "${NS}")
225 foreach (_MODULE_NAME IN LISTS ${NS}MODULES_REQUESTED)
226  # check if requested module is available
227  basis_find_config (MODULES_ENABLED ${_MODULE_NAME} _MODULE_IDX)
228  if (_MODULE_IDX EQUAL -1)
229  # set <Pkg>_<Module>_FOUND = FALSE
230  basis_set_config (${_MODULE_NAME}_FOUND FALSE)
231  # append to list of not found requested modules
232  basis_append_config (MODULES_NOTFOUND ${_MODULE_NAME})
233  else ()
234  set (_MODULE_NS "${NS}${_MODULE_NAME}_")
235  # include configuration file of module
236  set (${_MODULE_NAME}_CONFIG_PREFIX "${_MODULE_NS}")
237  include ("${${NS}MODULES_DIR}/BASIS${_MODULE_NAME}Config.cmake")
238  unset (${_MODULE_NAME}_CONFIG_PREFIX)
239  set (NS "${_PACKAGE_NS}") # restore NS of this package config
240  # append include directories
241  if (${_MODULE_NS}INCLUDE_DIRS)
242  basis_append_config (INCLUDE_DIRS ${${_MODULE_NS}INCLUDE_DIRS})
243  elseif (${_MODULE_NS}INCLUDE_DIR)
244  basis_append_config (INCLUDE_DIRS ${${_MODULE_NS}INCLUDE_DIR})
245  endif ()
246  # append library directories
247  if (${_MODULE_NS}LIBRARY_DIRS)
248  basis_append_config (LIBRARY_DIRS ${${_MODULE_NS}LIBRARY_DIRS})
249  elseif (${_MODULE_NS}LIBARY_DIR)
250  basis_append_config (LIBRARY_DIRS ${${_MODULE_NS}LIBRARY_DIR})
251  endif ()
252  # set <Pkg>_<Module>_FOUND = TRUE
253  basis_set_config (${_MODULE_NAME}_FOUND TRUE)
254  # append to list of found requested modules
255  basis_append_config (MODULES_FOUND ${_MODULE_NAME})
256  endif ()
257 endforeach ()
258 unset (_PACKAGE_NS)
259 
260 if (${NS}MODULES_NOTFOUND)
261  set (_REQUIRED)
262  set (_OPTIONAL)
263  set (_MISSING)
264  foreach (_MODULE_NAME IN LISTS ${NS}MODULES_REQUESTED)
265  if (${NS}FIND_REQUIRED_${_MODULE_NAME})
266  list (APPEND _REQUIRED ${_MODULE_NAME})
267  if (NOT ${NS}${_MODULE_NAME}_FOUND)
268  list (APPEND _MISSING ${_MODULE_NAME})
269  endif ()
270  else ()
271  list (APPEND _OPTIONAL ${_MODULE_NAME})
272  endif ()
273  endforeach ()
274  if (_MISSING)
275  message(FATAL_ERROR "Could not find all required BASIS components!"
276  " Rebuild and/or install the BASIS package with"
277  " the following modules enabled by setting MODULE_<name>"
278  " to ON when configuring the build of the package with CMake."
279  "\nOptional modules = [${_OPTIONAL}]"
280  "\nRequired modules = [${_REQUIRED}]"
281  "\nMissing modules = [${_MISSING}]\n")
282  endif ()
283  unset (_REQUIRED)
284  unset (_OPTIONAL)
285  unset (_MISSING)
286 endif ()
287 
288 unset (_MODULE_NAME)
289 unset (_MODULE_IDX)
290 unset (_MODULE_NS)
291 
292 # ============================================================================
293 # clean INCLUDE_DIRS and LIBRARY_DIRS
294 # ============================================================================
295 
296 basis_remove_duplicates_config (INCLUDE_DIR)
297 basis_remove_duplicates_config (INCLUDE_DIRS)
298 basis_remove_duplicates_config (LIBRARY_DIR)
299 basis_remove_duplicates_config (LIBRARY_DIRS)
300 
301 basis_remove_item_config (INCLUDE_DIRS "")
302 basis_remove_item_config (LIBRARY_DIRS "")
303 
304 # ============================================================================
305 # dependencies
306 # ============================================================================
307 
308 set (_depwarn " set to different value than during the configuration of BASIS."
309  " Using different versions of a dependency may cause inconsistencies!")
310 # Python
311 if (DEPENDS_Python_DIR)
312  if (NOT DEPENDS_Python_DIR STREQUAL "/usr/bin")
313  message (WARNING DEPENDS_Python_DIR ${_depwarn})
314  endif ()
315 else ()
316  basis_set_or_update_value (DEPENDS_Python_DIR "/usr/bin")
317 endif ()
318 # Jython
319 if (DEPENDS_Jython_DIR)
320  if (NOT DEPENDS_Jython_DIR STREQUAL "/usr/local/bin")
321  message (WARNING DEPENDS_Jython_DIR ${_depwarn})
322  endif ()
323 else ()
324  basis_set_or_update_value (DEPENDS_Jython_DIR "/usr/local/bin")
325 endif ()
326 # Perl
327 if (DEPENDS_Perl_DIR)
328  if (NOT DEPENDS_Perl_DIR STREQUAL "/usr/bin")
329  message (WARNING DEPENDS_Perl_DIR ${_depwarn})
330  endif ()
331 else ()
332  basis_set_or_update_value (DEPENDS_Perl_DIR "/usr/bin")
333 endif ()
334 # MATLAB
335 if (DEPENDS_MATLAB_DIR)
336  if (NOT DEPENDS_MATLAB_DIR STREQUAL "/Applications/MATLAB_R2016a.app")
337  message (WARNING DEPENDS_MATLAB_DIR ${_depwarn})
338  endif ()
339 else ()
340  basis_set_or_update_value (DEPENDS_MATLAB_DIR "/Applications/MATLAB_R2016a.app")
341 endif ()
342 # BASH
343 if (DEPENDS_BASH_DIR)
344  if (NOT DEPENDS_BASH_DIR STREQUAL "/bin")
345  message (WARNING DEPENDS_BASH_DIR ${_depwarn})
346  endif ()
347 else ()
348  basis_set_or_update_value (DEPENDS_BASH_DIR "/bin")
349 endif ()
350 unset (_depwarn)
351 
352 # ============================================================================
353 # BASIS configuration
354 # ============================================================================
355 
356 # ----------------------------------------------------------------------------
357 # CMake modules
358 
359 ## @brief Absolute path to CMake modules.
360 basis_set_config (MODULE_PATH "/Users/as12312/Software/BASIS/Workspace/src/cmake/modules")
361 
362 ## @brief Absolute path to CMake Find modules.
363 basis_set_config (FIND_MODULE_PATH "/Users/as12312/Software/BASIS/Workspace/src/cmake/find")
364 
365 # ----------------------------------------------------------------------------
366 # utilities
367 
368 ## @brief List of enabled BASIS utilities.
369 basis_set_config (UTILITIES_ENABLED "CXX;PYTHON;PERL;BASH")
370 
371 ## @brief Python interpreter used to build/configure BASIS Python modules.
372 basis_set_config (PYTHON_EXECUTABLE "/usr/bin/python")
373 ## @brief Jython interpreter used to build/configure BASIS Jython modules.
374 basis_set_config (JYTHON_EXECUTABLE "/usr/local/bin/jython")
375 ## @brief Perl interpreter used to build/configure BASIS Perl modules.
376 basis_set_config (PERL_EXECUTABLE "/usr/bin/perl")
377 ## @brief Bash executable used to build/configure BASIS Bash modules.
378 basis_set_config (BASH_EXECUTABLE "/bin/bash")
379 
380 ## @brief Absolute path to C++ utilities files.
381 basis_set_config (CXX_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/cxx")
382 ## @brief Absolute path to Python utilities files.
383 basis_set_config (PYTHON_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/python")
384 ## @brief Absolute path to Python utilities files.
385 basis_set_config (JYTHON_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/jython")
386 ## @brief Absolute path to Perl utilities files.
387 basis_set_config (PERL_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/perl")
388 ## @brief Absolute path to MATLAB utilities files.
389 basis_set_config (MATLAB_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/matlab")
390 ## @brief Absolute path to Bash utilities files.
391 basis_set_config (BASH_TEMPLATES_DIR "/Users/as12312/Software/BASIS/Workspace/src/utilities/bash")
392 
393 ## @brief C++ utilities library.
394 basis_set_config (CXX_UTILITIES_LIBRARY "basis.utilities_cxx")
395 ## @brief Python utilities library.
396 basis_set_config (PYTHON_UTILITIES_LIBRARY "basis.utilities_python")
397 ## @brief Jython utilities library.
398 basis_set_config (JYTHON_UTILITIES_LIBRARY "basis.")
399 ## @brief Perl utilities library.
400 basis_set_config (PERL_UTILITIES_LIBRARY "basis.utilities_perl")
401 ## @brief MATLAB utilities library.
402 basis_set_config (MATLAB_UTILITIES_LIBRARY "basis.")
403 ## @brief Bash utilities library.
404 basis_set_config (BASH_UTILITIES_LIBRARY "basis.utilities_bash")
405 
406 ## @brief Unit testing library.
407 basis_set_config (TEST_LIBRARY "basis.testlib")
408 ## @brief Implementation of main() function of unit test driver.
409 basis_set_config (TEST_MAIN_LIBRARY "basis.testmain")
410 
411 ## @brief Main libraries.
412 basis_set_config (LIBRARIES
413  ${${NS}UTILITIES_LIBRARY}
414  ${${NS}TEST_LIBRARY}
415 )
416 
417 # ----------------------------------------------------------------------------
418 # Sphinx
419 
420 ## @brief Path of Sphinx extensions.
421 basis_set_config (SPHINX_EXTENSIONS_PATH "/Users/as12312/Software/BASIS/Xcode/lib/python/basis/sphinx/ext")
422 ## @brief Path of Sphinx HTML themes.
423 basis_set_config (SPHINX_HTML_THEME_PATH "/Users/as12312/Software/BASIS/Workspace/src/sphinx/themes")
424 
425 # ----------------------------------------------------------------------------
426 # CMake tools
427 
428 include ("${${NS}MODULE_PATH}/BasisSettings.cmake" NO_POLICY_SCOPE)
429 include ("${${NS}MODULE_PATH}/BasisTools.cmake")
430 
431 
432 ## @}
433 # end of Doxygen group - keep at end of file
macro basis_append_config(in NAME)
cmake LIBRARY_DIR
Directory of shared and module libraries relative to script location.
cmake EXPORTS_FILE
Name of the CMake target exports file.
cmake _MODULE_NAME
macro basis_set_or_update_value(in VAR)
cmake USE_FILE
Name of the CMake package use file.
Definition: basis.h:34
cmake NAME
cmake _MODULE_NS
cmake COMMAND
macro basis_find_config(in NAME, in VALUE, in IDX)
cmake VALUE
cmake CONFIG_PREFIX
Package name.
cmake _PACKAGE_NS
List of modules requested by external package using the COMPONENTS argument of find_package().
cmake NS
macro basis_remove_item_config(in NAME, in ITEM)
cmake CUSTOM_EXPORTS_FILE
Name of the CMake target exports file for custom targets.
macro basis_is_cached(in VAR, in ENTRY)
macro basis_remove_duplicates_config(in NAME)
macro basis_copy_config(in NAME, in SRC)
macro basis_set_config(in NAME)
function get_filename_component(inout ARGN)
Fixes CMake&#39;s get_filename_component() command.