forked from BioMedIA/MIRTK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
204 lines (190 loc) · 6.96 KB
/
CMakeLists.txt
File metadata and controls
204 lines (190 loc) · 6.96 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# ============================================================================
# Medical Image Registration ToolKit (MIRTK)
#
# Copyright 2013-2016 Imperial College London
# Copyright 2013-2016 Andreas Schuh
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# ============================================================================
##############################################################################
# @file CMakeLists.txt
# @brief Root build configuration file.
#
# @note This package utilizes <a href="http://opensource.andreasschuh.com/cmake-basis">CMake BASIS</a>.
#
##############################################################################
# ----------------------------------------------------------------------------
# Minimum required CMake version
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
# ----------------------------------------------------------------------------
# Include BASIS policies, settings, macros, and functions
set(BASIS_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Basis")
set(MIRTK_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules")
set(CMAKE_MODULE_PATH "${MIRTK_MODULE_PATH}" "${BASIS_MODULE_PATH}")
include(mirtkPolicies NO_POLICY_SCOPE)
include(BasisSettings)
include(BasisTools)
include(mirtkTools)
# ----------------------------------------------------------------------------
# Configure build system
# Initialize project
mirtk_project_begin()
# Main "mirtk" script
#
# This wrapper script sets up the environment and executes the specified
# subcommand. Do not use mirtk_add_executable which is only used for
# commands that are executed by this wrapper script.
if (BUILD_APPLICATIONS)
basis_add_executable("${PROJECT_TOOLS_DIR}/mirtk.py")
endif ()
# Add auxiliary command used to (re-)format help output
#
# Note: Added as first application because mirtk_add_executable adds a
# dependency on this target for each command to generate the documentation
# when BUILD_DOCUMENTATION is ON.
if (BUILD_APPLICATIONS)
basis_add_executable(help-rst "${PROJECT_TOOLS_DIR}/help-rst.py" LIBEXEC)
basis_set_target_properties(help-rst PROPERTIES OUTPUT_NAME "mirtk-help-rst")
basis_set_project_property(APPEND PROPERTY MIRTK_COMMANDS help-rst)
basis_add_dependencies(help-rst mirtk)
endif ()
# Process modules
foreach (MODULE IN LISTS PROJECT_MODULES_ENABLED)
basis_add_module(${MODULE})
basis_use_module(${MODULE})
endforeach ()
# Process subdirectories
foreach (SUBDIR IN LISTS PROJECT_SUBDIRS)
basis_add_subdirectory(${SUBDIR})
endforeach ()
# Install CMake modules
basis_add_subdirectory(CMake)
# Finalize project
mirtk_project_end()
# ------------------------------------------------------------------------------
# Generate Bash completions file
if (UNIX)
get_property(COMMANDS GLOBAL PROPERTY MIRTK_COMMANDS)
list(REMOVE_ITEM COMMANDS help-rst)
if (COMMANDS)
message(STATUS "Writing Bash completions script...")
basis_list_to_delimited_string(COMMANDS " " ${COMMANDS})
file(WRITE "${PROJECT_BINARY_DIR}/share/completion/bash/mirtk"
"
# Auto-generated by MIRTK root CMakeLists.txt during CMake configure.
#
# To enable Bash completion of \"mirtk\" subcommands, add the following to your
# ~/.bashrc (Linux) or ~/.bash_profile (OS X) file:
#
# [ ! -f \"\$MIRTK_ROOT/share/completion/bash/mirtk\" ] ||
# source \"\$MIRTK_ROOT/share/completion/bash/mirtk\"
# [ ! -f \"\$MIRTK_ROOT/share/mirtk/completion/bash/mirtk\" ] ||
# source \"\$MIRTK_ROOT/share/mirtk/completion/bash/mirtk\"
#
# Alternatively, copy this file to:
# - /etc/bash_completion.d/ (Linux)
# - \$(brew --prefix)/etc/bash_completion.d/ (OS X, Homebrew)
#
_mirtk_complete()
{
local commands='${COMMANDS}'
local noreply='true'
if [ \$COMP_CWORD -eq 2 ]; then
if [ \${COMP_WORDS[1]} = help ] || [ \${COMP_WORDS[1]} = help-rst ]; then
COMPREPLY=( `compgen -W \"\$commands\" -- \${COMP_WORDS[COMP_CWORD]}` )
noreply='false'
fi
elif [ \$COMP_CWORD -eq 1 ]; then
COMPREPLY=( `compgen -W \"help help-rst \$commands\" -- \${COMP_WORDS[COMP_CWORD]}` )
noreply='false'
fi
if [ \$noreply = true ]; then
local IFS=$'\n'
COMPREPLY=(`compgen -o plusdirs -f -- \"\${COMP_WORDS[COMP_CWORD]}\"`)
compopt -o filenames +o nospace 2>/dev/null || compgen -f /non-existing-dir/ > /dev/null
fi
}
complete -F _mirtk_complete mirtk
"
)
file(WRITE "${PROJECT_BINARY_DIR}/share/completion/bash/docker-mirtk"
"
# Auto-generated by MIRTK root CMakeLists.txt during CMake configure.
#
# To enable Bash completion for \"docker run [options] <user>/mirtk\" subcommands:
#
# - On Linux:
# - Copy this file to /etc/bash_completion.d/:
#
# - On OS X with Homebrew:
# - brew install bash-completion
# - curl -L https://raw.githubusercontent.com/docker/docker/master/contrib/completion/bash/docker > \$(brew --prefix)/etc/bash_completion.d/docker
# - Copy this file to \$(brew --prefix)/etc/bash_completion.d/:
#
_docker_mirtk()
{
local commands='${COMMANDS}'
local noreply='true'
local nodocker='false'
if [ \$COMP_CWORD -gt 2 ] && [ \${COMP_WORDS[1]} = run ]; then
local i
let i=\$COMP_CWORD-1
if [ \${COMP_WORDS[i]/*\\//} = mirtk ]; then
COMPREPLY=( `compgen -W \"help help-rst \$commands\" -- \${COMP_WORDS[COMP_CWORD]}` )
nodocker='true'
noreply='false'
elif [ \${COMP_WORDS[i]} = help ]; then
let i=\$i-1
if [ \${COMP_WORDS[i]/*\\//} = mirtk ]; then
COMPREPLY=( `compgen -W \"\$commands\" -- \${COMP_WORDS[COMP_CWORD]}` )
nodocker='true'
noreply='false'
fi
else
local word
for word in \${COMP_WORDS[@]}; do
if [ \${word/*\\//} = mirtk ]; then
nodocker='true'
noreply='true'
fi
done
fi
fi
if [ \$nodocker = false ]; then
# call docker completion function instead
# https://raw.githubusercontent.com/docker/docker/master/contrib/completion/bash/docker
declare -f _docker > /dev/null
if [ \$? -eq 0 ]; then
_docker
noreply='false'
fi
fi
if [ \$noreply = true ]; then
local IFS=$'\n'
COMPREPLY=(`compgen -o plusdirs -f -- \"\${COMP_WORDS[COMP_CWORD]}\"`)
compopt -o filenames +o nospace 2>/dev/null || compgen -f /non-existing-dir/ > /dev/null
fi
}
complete -F _docker_mirtk docker
"
)
install(
FILES
"${PROJECT_BINARY_DIR}/share/completion/bash/mirtk"
"${PROJECT_BINARY_DIR}/share/completion/bash/docker-mirtk"
DESTINATION
"${INSTALL_SHARE_DIR}/completion/bash"
)
message(STATUS "Writing Bash completions script... done")
endif ()
endif ()