forked from Slicer/Slicer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlicerCheckModuleEnabled.cmake
93 lines (88 loc) · 3.62 KB
/
SlicerCheckModuleEnabled.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) Kitware Inc.
#
# See COPYRIGHT.txt
# or http://www.slicer.org/copyright/copyright.txt for details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 1R01EB021391
#
################################################################################
#
# This CMake module provides functions allowing to check if a given Slicer built-in module
# should be enabled or disabled.
#
# Definitions:
#
# * A Slicer built-in module is a module whose source code is found under one of the
# "Slilcer/Modules/*" subdirectories. These do not include Slicer remote modules or
# modules associated with bundled extensions.
#
# * Enabling (or disabling) a module means that it will (or will not) be built.
#
# * Building a module means that the corresponding directory is added using the add_subdirectory
# CMake command and that the associated CMakeLists.txt is processed.
#
# By default, all built-in Slicer modules are assumed to be enabled. Then, based on Slicer
# build options, built-in module may be disabled.
#
# Setting any of these variables allows to explicitly disable modules of the
# corresponding module type ignoring effect of Slicer build options:
# * Slicer_CLIMODULES_DISABLED
# * Slicer_QTLOADABLEMODULES_DISABLED
# * Slicer_QTSCRIPTEDMODULES_DISABLED
#
# Setting any of these variables allows to explicitly list the modules
# to be built ignoring effect of Slicer build options:
# * Slicer_CLIMODULES_ENABLED
# * Slicer_QTLOADABLEMODULES_ENABLED
# * Slicer_QTSCRIPTEDMODULES_ENABLED
#
# For a given module type (CLIMODULES, QTLOADABLEMODULES or QTSCRIPTEDMODULES), setting the
# Slicer_<module_type>_ENABLED variable will cause any module list in the Slicer_<module_type>_DISABLED
# variables to be ignored.
#
# Finally, the following functions allows to check if a given module is enabled or disabled:
#
# slicer_is_cli_builtin_module_enabled(<modulename> <output_var>)
#
# slicer_is_loadable_builtin_module_enabled(<modulename> <output_var>)
#
# slicer_is_scripted_builtin_module_enabled(<modulename> <output_var>)
#
macro(slicer_is_cli_builtin_module_enabled module_name output_var)
_slicer_is_module_enabled("Slicer_CLIMODULES" ${module_name} ${output_var})
endmacro()
macro(slicer_is_loadable_builtin_module_enabled module_name output_var)
_slicer_is_module_enabled("Slicer_QTLOADABLEMODULES" ${module_name} ${output_var})
endmacro()
macro(slicer_is_scripted_builtin_module_enabled module_name output_var)
_slicer_is_module_enabled("Slicer_QTSCRIPTEDMODULES" ${module_name} ${output_var})
endmacro()
function(_slicer_is_module_enabled enabling_var_prefix module_name output_var)
set(_build_module 1)
# Is module explicitly disabled ?
if(${enabling_var_prefix}_DISABLED)
list(FIND ${enabling_var_prefix}_DISABLED ${module_name} _module_disabled)
if(${_module_disabled} GREATER -1)
set(_build_module 0)
endif()
endif()
# Is module explicitly enabled ?
if(${enabling_var_prefix}_ENABLED)
list(FIND ${enabling_var_prefix}_ENABLED ${module_name} _module_enabled)
if(NOT ${_module_enabled} GREATER -1)
set(_build_module 0)
endif()
endif()
set(${output_var} ${_build_module} PARENT_SCOPE)
endfunction()