BASISUse.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 BASISUse.cmake
12 # @brief CMake package configuration use file.
13 #
14 # @note The BASISUse.cmake file is automatically generated
15 # by BASIS from the template file ConfigUse.cmake.in which is part of
16 # the BASIS package.
17 #
18 # In the default package use file of BASIS, which can be included here using
19 # the \@BASIS_USE\@ variable, the prefix used by the package configuration
20 # file is defined as @c NS variable. Thus, to use any variable set by the
21 # corresponding package configuration file, use code similar to:
22 #
23 # @code
24 # include_directories (${${NS}INCLUDE_DIRS})
25 # @endcode
26 #
27 # See the ConfigUse.cmake.in file of BASIS for details.
28 #
29 # @note The CMake code which is substituted for the \@BASIS_USE\@ variable
30 # contains an include guard.
31 #
32 # @ingroup BasisConfig
33 ##############################################################################
34 
35 # ============================================================================
36 # additional BASIS modules
37 # ============================================================================
38 
39 # The basic tools are included by BASISConfig.cmake already.
40 # Additional modules required by this project are included here.
41 # The include of the ImportTools must occur **before** the include of
42 # the exported CMake BASIS targets itself below.
43 
45  include (${BASIS_MODULE_PATH}/ImportTools.cmake)
46 endif ()
47 if (BASIS_SUPER_BUILD_MODULES)
48  include (${BASIS_MODULE_PATH}/SuperBuildTools.cmake)
49 endif ()
50 
51 # ============================================================================
52 # Basic configuration
53 # ============================================================================
54 
55 # ============================================================================
56 # namespace
57 # ============================================================================
58 
59 # prefix used for variable names
60 set (NS "BASIS_")
61 
62 # allow caller to change namespace - used by projects with modules
63 if (${NS}CONFIG_PREFIX)
64  set (NS "${${NS}CONFIG_PREFIX}_")
65 endif ()
66 
67 # ============================================================================
68 # include guard
69 # ============================================================================
70 
71 if (__${NS}USE_FILE_INCLUDED)
72  return ()
73 else ()
74  set (__${NS}USE_FILE_INCLUDED 1)
75 endif ()
76 
77 # ============================================================================
78 # use project settings
79 # ============================================================================
80 
81 # include directories
82 if (${NS}INCLUDE_DIRS)
83  include_directories (${${NS}INCLUDE_DIRS})
84 elseif (${NS}INCLUDE_DIR)
85  include_directories (${${NS}INCLUDE_DIR})
86 endif ()
87 
88 # library directories
89 if (${NS}LIBRARY_DIRS)
90  link_directories (${${NS}LIBRARY_DIRS})
91 elseif (${NS}LIBRARY_DIR)
93 endif ()
94 
95 # ============================================================================
96 # import build targets
97 # ============================================================================
98 
99 ## @brief Whether to import the exported targets.
100 set (NO_${NS}IMPORTS "${NO_${NS}IMPORTS}")
101 
102 if (NOT NO_${NS}IMPORTS)
103  include ("${${NS}EXPORTS_FILE}" OPTIONAL)
104  include ("${${NS}CUSTOM_EXPORTS_FILE}" OPTIONAL)
105 endif ()
106 
107 # ============================================================================
108 # use modules
109 # ============================================================================
110 
111 foreach (M IN LISTS ${NS}MODULES_REQUESTED)
112  if (${NS}${M}_USE_FILE)
113  set (${M}_CONFIG_PREFIX "${NS}${M}_")
114  include ("${${NS}${M}_USE_FILE}")
115  unset (${M}_CONFIG_PREFIX)
116  endif ()
117 endforeach ()
118 
119 # ============================================================================
120 # BASIS configuration
121 # ============================================================================
122 
123 # ----------------------------------------------------------------------------
124 # Add CMake BASIS Find Modules path to CMAKE_MODULE_PATH
125 list (INSERT CMAKE_MODULE_PATH 0 "${BASIS_FIND_MODULE_PATH}")
126 list (REMOVE_DUPLICATES CMAKE_MODULE_PATH)
127 
128 # ----------------------------------------------------------------------------
129 # Import configured script executables
130 
131 # The following statements ensure that all scripts and modules are
132 # configured/compiled using the same version of the interpreters.
133 # Yet, the user can modify these variables, though this is not recommended.
134 
135 # Note: The PERL_EXECUTABLE, and BASH_EXECUTABLE variables have to be cached
136 # such that the FindPerl.cmake, and FindBASH.cmake modules find the
137 # respective executable.
138 #
139 # Attention: DO NOT set PYTHON_EXECUTABLE here. In case of a Slicer Extension,
140 # the UseSlicer.cmake file requires us not to set PYTHON_EXECUTABLE
141 # before including this file. As the BASISUse.cmake file is included
142 # before any other dependency, the PYTHON_EXECUTABLE variable is
143 # set by the basis_project_impl() macro.
144 
145 ## @brief Jython interpreter configured when building BASIS.
146 if (BASIS_JYTHON_EXECUTABLE)
147  set (
148  JYTHON_EXECUTABLE
149  "${BASIS_JYTHON_EXECUTABLE}"
150  CACHE PATH
151  "The Jython interpreter."
152  )
153  mark_as_advanced (JYTHON_EXECUTABLE)
154 endif ()
155 
156 ## @brief Perl interpreter configured when building BASIS.
157 if (BASIS_PERL_EXECUTABLE)
158  set (
159  PERL_EXECUTABLE
160  "${BASIS_PERL_EXECUTABLE}"
161  CACHE PATH
162  "The Perl interpreter."
163  )
164  mark_as_advanced (PERL_EXECUTABLE)
165 endif ()
166 
167 ## @brief Bash executable configured when building BASIS.
168 if (BASIS_BASH_EXECUTABLE)
169  set (
170  BASH_EXECUTABLE
171  "${BASIS_BASH_EXECUTABLE}"
172  CACHE PATH
173  "The BASH executable."
174  )
175  mark_as_advanced (BASH_EXECUTABLE)
176 endif ()
string OPTIONAL
Definition: argparse.py:128
cmake LIBRARY_DIR
Directory of shared and module libraries relative to script location.
cmake BASIS_IMPORT_TARGETS
Enable/disable import of targets using the BASIS ImportTools.
macro include_directories(in ARGN)
Add directories to search path for include files.
macro link_directories(in ARGN)
Add directories to search path for libraries.
cmake NS
Definition: BASISUse.cmake:35
cmake CONFIG_PREFIX
Package name.