forked from InsightSoftwareConsortium/ITKTubeTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
746 lines (638 loc) · 27.5 KB
/
CMakeLists.txt
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
##############################################################################
#
# Library: TubeTK
#
# Copyright 2010 Kitware Inc. 28 Corporate Drive,
# Clifton Park, NY, 12065, USA.
#
# All rights reserved.
#
# 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.
#
##############################################################################
project( TubeTK )
# Require CMake 2.8 for its superbuild functionality.
cmake_minimum_required( VERSION 2.8.7 )
# Update CMake module path
set( TubeTK_CMAKE_EXTENSIONS_DIR ${TubeTK_SOURCE_DIR}/CMake )
set( CMAKE_MODULE_PATH ${TubeTK_CMAKE_EXTENSIONS_DIR} ${CMAKE_MODULE_PATH} )
# Set TubeTK version and output directories.
set( TubeTK_VERSION_MAJOR "0" )
set( TubeTK_VERSION_MINOR "9" )
set( TubeTK_VERSION_PATCH "0" )
include( TubeTKFunctionToday )
TubeTKFunctionToday( TubeTK_VERSION_BUILD )
set( TubeTK_VERSION
"${TubeTK_VERSION_MAJOR}.${TubeTK_VERSION_MINOR}.${TubeTK_VERSION_PATCH}.${TubeTK_VERSION_BUILD}" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/TubeTK" )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/TubeTK" )
include( TubeTKBlockSetCMakeOSXVariables )
include( TubeTKMacroEmptyExternalProject )
# Setup for building 3D Slicer extensions.
option( TubeTK_BUILD_SLICER_EXTENSION
"Build TubeTK as a 3D Slicer extension." OFF )
if( TubeTK_BUILD_SLICER_EXTENSION )
set( EXTENSION_NAME TubeTK )
set( EXTENSION_HOMEPAGE "http://www.tubetk.org" )
set( EXTENSION_CATEGORY "TubeTK" )
set( EXTENSION_CONTRIBUTORS "TubeTK Team at Kitware, Inc." )
set( EXTENSION_DESCRIPTION
"Using local image geometry for segmentation, registration, and filtering" )
set( EXTENSION_ICONURL
"http://public.kitware.com/Wiki/images/a/ad/TubeTK_Icon.jpg" )
set( EXTENSION_SCREENSHOTURLS
"http://public.kitware.com/Wiki/images/f/fd/VesselExtraction.jpg" )
set( EXTENSION_README_FILE ${TubeTK_SOURCE_DIR}/README.md )
set( EXTENSION_LICENSE_FILE ${TubeTK_SOURCE_DIR}/LICENSE.md )
endif( TubeTK_BUILD_SLICER_EXTENSION )
# CDash dashboard setup.
include( CTest )
if( BUILD_TESTING )
set( BUILDNAME "${BUILDNAME}" CACHE STRING
"Name of the build on the CDash dashboard." )
mark_as_advanced( BUILDNAME )
endif( BUILD_TESTING )
set( BUILD_WARNING_REPORT_LIMIT -1 )
set( BUILD_ERROR_REPORT_LIMIT -1 )
include( CTestConfig.cmake )
configure_file( ${TubeTK_SOURCE_DIR}/CMake/CTestCustom.cmake.in
${TubeTK_BINARY_DIR}/CTestCustom.cmake )
# Configure for the download of CTest unit testing data from a Midas Platform
# server.
set( MIDAS_USER "" CACHE STRING "Midas Platform user email address." )
mark_as_advanced( MIDAS_USER )
set( MIDAS_DEFAULT_API_KEY "" CACHE STRING "Midas Platform default API key." )
mark_as_advanced( MIDAS_DEFAULT_API_KEY )
set( MIDAS_DATA_DIR ${TubeTK_BINARY_DIR}/MIDAS_Data )
# Doxygen documentation setup.
option( BUILD_DOCUMENTATION
"Build the software guide and source code documentation." OFF )
if( BUILD_DOCUMENTATION )
option( TubeTK_USE_DOXYGEN
"Use Doxygen to generate the source code documentation." ON )
mark_as_advanced( TubeTK_USE_DOXYGEN )
if( TubeTK_USE_DOXYGEN )
add_subdirectory( CMake/Doxygen )
endif( TubeTK_USE_DOXYGEN )
endif( BUILD_DOCUMENTATION )
# Microsoft Visual Studio setup.
if( MSVC )
add_definitions( -D_SCL_SECURE_NO_WARNINGS )
if( NOT CMAKE_FIRST_PASS_COMPLETED AND "${CMAKE_CXX_COMPILER}" MATCHES "cl" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /MP"
CACHE STRING "Flags used by all build types." FORCE )
endif( NOT CMAKE_FIRST_PASS_COMPLETED AND "${CMAKE_CXX_COMPILER}" MATCHES "cl" )
option( DISABLE_MSVC8_DEPRECATED_WARNINGS
"Disable Microsoft Visual Studio 8 deprecated warnings." ON )
mark_as_advanced( FORCE DISABLE_MSVC8_DEPRECATED_WARNINGS )
if( DISABLE_MSVC8_DEPRECATED_WARNINGS )
add_definitions( -D_CRT_SECURE_NO_DEPRECATE )
endif( DISABLE_MSVC8_DEPRECATED_WARNINGS )
endif( MSVC )
# Apple OS X setup.
if( APPLE )
if( NOT CMAKE_FIRST_PASS_COMPLETED )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common"
CACHE STRING "Flags used by all build types." FORCE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-common"
CACHE STRING "Flags used by all build types." FORCE )
endif( NOT CMAKE_FIRST_PASS_COMPLETED )
endif( APPLE )
# Linux or UNIX setup.
if( UNIX )
if( NOT CMAKE_FIRST_PASS_COMPLETED )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing"
CACHE STRING "Flags used by all build types." FORCE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing"
CACHE STRING "Flags used by all build types." FORCE )
if( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC"
CACHE STRING "Flags used by all build types." FORCE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC"
CACHE STRING "Flags used by all build types." FORCE )
endif( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
endif( NOT CMAKE_FIRST_PASS_COMPLETED )
endif( UNIX )
# Implementation agnostic fPIC
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
# Slicer library setup.
# If available, Slicer can be used to retrieve external libraries and modules
# used by TubeTK.
option( TubeTK_USE_SLICER "Use Slicer to extract useful commands and CLIs."
OFF )
# If USE_SYSTEM_SLICER is OFF, it still won't be built as an external project.
option( USE_SYSTEM_SLICER
"Use 3D Slicer to configure dependencies such as ITK, VTK, CTK..." ON )
mark_as_advanced( USE_SYSTEM_SLICER )
# Slicer must be used if TubeTK is built as an extension.
if( TubeTK_BUILD_SLICER_EXTENSION )
set( TubeTK_USE_SLICER ON CACHE BOOL
"Use 3D Slicer to extract useful commands and CLIs." FORCE )
endif( TubeTK_BUILD_SLICER_EXTENSION )
if( TubeTK_USE_SLICER AND USE_SYSTEM_SLICER )
unset( QT_QMAKE_EXECUTABLE )
# Find Slicer to set the [ITK|VTK|CTK|...]_DIR variables
find_package( Slicer REQUIRED )
set( Slicer_DONT_USE_EXTENSION ${TubeTK_BUILD_SLICER_EXTENSION} )
include( ${Slicer_USE_FILE} )
# TubeTK_SLICER_SOURCE_DIR is needed to get ExpertAutomatedRegistration CLI
if( Slicer_SOURCE_DIR )
set( TubeTK_SLICER_SOURCE_DIR ${Slicer_SOURCE_DIR} )
else( Slicer_SOURCE_DIR )
set( TubeTK_SLICER_SOURCE_DIR ${Slicer_CMAKE_DIR}/.. )
endif( Slicer_SOURCE_DIR )
# All those dependencies are already provided by Slicer
set( USE_SYSTEM_ITK ON CACHE BOOL
"Exclude ITK from superbuild and use an existing build." FORCE )
set( TubeTK_USE_VTK ON CACHE BOOL
"Use VTK to enable additional functionality." FORCE )
set( USE_SYSTEM_VTK ON CACHE BOOL
"Exclude VTK from superbuild and use an existing build." FORCE )
set( TubeTK_USE_QT ON CACHE BOOL
"Use the Qt framework to enable additional functionality."
FORCE )
set( TubeTK_USE_CTK ON CACHE BOOL
"Use CTK to enable additional functionality."
FORCE )
set( USE_SYSTEM_CTK ON CACHE BOOL
"Exclude CTK from superbuild and use an existing build." FORCE )
set( USE_SYSTEM_SLICER_EXECUTION_MODEL ON CACHE BOOL
"Exclude SlicerExecutionModel from superbuild and use an existing build."
FORCE )
endif( TubeTK_USE_SLICER AND USE_SYSTEM_SLICER )
# Boost libraries setup.
option( TubeTK_USE_BOOST
"Use the Boost libraries to enable additional functionality." OFF )
if( TubeTK_USE_BOOST )
find_package( Boost REQUIRED )
if( NOT Boost_FOUND )
set( BOOST_ROOT "NOT_FOUND" CACHE PATH
"Path to the top-level directory of Boost." FORCE )
mark_as_advanced( CLEAR BOOST_ROOT )
endif( NOT Boost_FOUND )
endif( TubeTK_USE_BOOST )
# Cppcheck setup.
option( TubeTK_USE_CPPCHECK "Use Cppcheck to enable additional tests." OFF )
set( USE_SYSTEM_CPPCHECK_DEFAULT OFF )
if( WIN32 )
set( USE_SYSTEM_CPPCHECK_DEFAULT ON )
endif( WIN32 )
option( USE_SYSTEM_CPPCHECK
"Exclude Cppcheck from superbuild and use an existing build."
${USE_SYSTEM_CPPCHECK_DEFAULT} )
mark_as_advanced( USE_SYSTEM_CPPCHECK )
# CTK setup.
option( TubeTK_USE_CTK "Use CTK to enable additional functionality." OFF )
option( USE_SYSTEM_CTK
"Exclude CTK from superbuild and use an existing build." OFF )
mark_as_advanced( USE_SYSTEM_CTK )
# Image viewer setup.
option( TubeTK_USE_IMAGE_VIEWER "Use ImageViewer." OFF )
option( USE_SYSTEM_IMAGE_VIEWER
"Exclude ImageViewer from superbuild and use an existing build." OFF )
mark_as_advanced( USE_SYSTEM_IMAGE_VIEWER )
option( TubeTK_USE_PYTHON "Use Python to enable additional functionality." OFF )
if( TubeTK_USE_PYTHON )
# NumPy conversion support.
option( TubeTK_USE_NUMPY "Use NumPy to enable additional functionality." ON )
mark_as_advanced( TubeTK_USE_NUMPY )
# Test TubeTK examples via Python virtualenv.
option( TubeTK_USE_NOTEBOOKS
"Test IPython notebooks in a Python virtualenv." ON )
mark_as_advanced( TubeTK_USE_NOTEBOOKS )
# PyQtGraph bridge support.
option( TubeTK_USE_PYQTGRAPH
"Use PyQtGraph to enable additional functionality." OFF )
mark_as_advanced( TubeTK_USE_PYQTGRAPH )
endif( TubeTK_USE_PYTHON )
# ITK setup.
option( USE_SYSTEM_ITK "Exclude ITK from superbuild and use an existing build."
OFF )
mark_as_advanced( USE_SYSTEM_ITK )
# JsonCpp library setup.
option( USE_SYSTEM_JSONCPP
"Exclude JsonCpp from superbuild and use an existing build." OFF )
mark_as_advanced( USE_SYSTEM_JSONCPP )
# KWStyle setup.
option( TubeTK_USE_KWSTYLE
"Use KWStyle to check for coding standards violations." OFF )
option( USE_SYSTEM_KWSTYLE
"Exclude KWStyle from superbuild and use an existing build." OFF )
mark_as_advanced( USE_SYSTEM_KWSTYLE )
# LIBSVM setup.
option( TubeTK_USE_LIBSVM "Use LIBSVM to enable additional functionality." OFF )
option( USE_SYSTEM_LIBSVM
"Exclude LIBSVM from superbuild and use an existing build." OFF )
mark_as_advanced( USE_SYSTEM_LIBSVM )
# Parameter serializer setup.
option( USE_SYSTEM_PARAMETER_SERIALIZER
"Exclude parameter serializer from superbuild and use an existing build."
OFF )
mark_as_advanced( USE_SYSTEM_PARAMETER_SERIALIZER )
# Qt framework setup.
option( TubeTK_USE_QT
"Use the Qt framework to enable additional applications and libraries." OFF )
if( TubeTK_USE_QT )
find_package( Qt4 )
# 3D Slicer only tests against a specific Qt 4 version. To
# override the version check, set the TubeTK_REQUIRED_QT_VERSION CMake
# variable.
if( NOT DEFINED TubeTK_REQUIRED_QT_VERSION )
set( TubeTK_REQUIRED_QT_VERSION "4.7.4" CACHE STRING
"Exact Qt framework version required." FORCE )
mark_as_advanced( TubeTK_REQUIRED_QT_VERSION )
endif( NOT DEFINED TubeTK_REQUIRED_QT_VERSION )
if( QT4_FOUND )
if( NOT "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}"
VERSION_EQUAL "${TubeTK_REQUIRED_QT_VERSION}" )
message( FATAL_ERROR
"Error: TubeTK requires Qt version ${TubeTK_REQUIRED_QT_VERSION}" )
endif( NOT "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}"
VERSION_EQUAL "${TubeTK_REQUIRED_QT_VERSION}" )
include( ${QT_USE_FILE} )
else( QT4_FOUND )
message( SEND_ERROR "Error: Qt framework not found." )
endif( QT4_FOUND )
endif( TubeTK_USE_QT )
# Slicer Execution model Setup
option( USE_SYSTEM_SLICER_EXECUTION_MODEL
"Exclude SlicerExecutionModel from superbuild and use an existing build."
OFF )
mark_as_advanced( USE_SYSTEM_SLICER_EXECUTION_MODEL )
option( TubeTK_USE_VALGRIND "Use Valgrind to enable additional functionality."
OFF )
mark_as_advanced( TubeTK_USE_VALGRIND )
# VTK setup.
option( TubeTK_USE_VTK "Use VTK to enable additional functionality." ON )
option( USE_SYSTEM_VTK "Exclude VTK from superbuild and use an existing build."
OFF )
mark_as_advanced( USE_SYSTEM_VTK )
# Modules
option( TubeTK_BUILD_MODULES
"Build modules. If not, only TubeTK library is built" ON )
# Indicate that this CMakeLists.txt file has already been parsed once. Keeps
# append commands from having an effect every time CMake is run.
set( CMAKE_FIRST_PASS_COMPLETED ON CACHE BOOL
"Modify the cache variables only on the first pass through the CMake file."
FORCE )
mark_as_advanced( CMAKE_FIRST_PASS_COMPLETED )
# Superbuild setup.
set( superbuild_enabled_by_default ON )
if( TubeTK_BUILD_SLICER_EXTENSION )
set( superbuild_enabled_by_default OFF )
endif( TubeTK_BUILD_SLICER_EXTENSION )
option( TubeTK_USE_SUPERBUILD
"Build TubeTK and the projects it depends on using a superbuild."
${superbuild_enabled_by_default} )
mark_as_advanced( TubeTK_USE_SUPERBUILD )
# If TubeTK_CONFIG_BINARY_DIR isn't defined, it means TubeTK is *NOT* build
# using Superbuild. In that specific case, TubeTK_CONFIG_BINARY_DIR should
# default to TubeTK_BINARY_DIR
if( NOT DEFINED TubeTK_CONFIG_BINARY_DIR )
set( TubeTK_CONFIG_BINARY_DIR ${CMAKE_BINARY_DIR} )
endif( NOT DEFINED TubeTK_CONFIG_BINARY_DIR )
if( TubeTK_USE_SUPERBUILD )
if( TubeTK_BUILD_MODULES )
# Expose the TubeTK_BUILD_* variables to Superbuild
file( GLOB_RECURSE TubeTK_modules_files "TubeTKModules.cmake" )
foreach( f ${TubeTK_modules_files} )
include( ${f} )
endforeach( f ${TubeTK_modules_files} )
endif( TubeTK_BUILD_MODULES )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Superbuild" )
return()
endif( TubeTK_USE_SUPERBUILD )
set( TubeTK_INSTALL_BIN_DIR "bin" )
set( TubeTK_INSTALL_LIB_DIR "lib/TubeTK" )
set( TubeTK_INSTALL_INCLUDE_DIR "include/TubeTK" )
set( TubeTK_INSTALL_SHARE_DIR "share/TubeTK" )
set( TubeTK_INSTALL_PLUGINS_BIN_DIR "${TubeTK_INSTALL_BIN_DIR}" )
set( TubeTK_INSTALL_PLUGINS_CACHE_DIR "${TubeTK_INSTALL_LIB_DIR}/CACHE" )
set( TubeTK_INSTALL_PLUGINS_INCLUDE_DIR "${TubeTK_INSTALL_INCLUDE_DIR}" )
set( TubeTK_INSTALL_PLUGINS_LIB_DIR "${TubeTK_INSTALL_LIB_DIR}" )
set( TubeTK_INSTALL_PLUGINS_SHARE_DIR "${TubeTK_INSTALL_SHARE_DIR}" )
if( TubeTK_USE_CPPCHECK )
list( APPEND CMAKE_MODULE_PATH "${TubeTK_SOURCE_DIR}/CMake/Cppcheck" )
find_package( Cppcheck REQUIRED )
set( CPPCHECK_PATHS_TO_CHECK "${TubeTK_SOURCE_DIR}/Applications"
"${TubeTK_SOURCE_DIR}/Base" )
set( CPPCHECK_SUPPRESSIONS_FILE
"${TubeTK_SOURCE_DIR}/CMake/Cppcheck/TubeTKCppcheckSuppressions.txt" )
set( CPPCHECK_COMMAND_PREFIX "${CPPCHECK_EXECUTABLE}" -q --xml --suppressions
"${CPPCHECK_SUPPRESSIONS_FILE}" )
add_test( Cppcheck
${CPPCHECK_COMMAND_PREFIX} --enable=all ${CPPCHECK_PATHS_TO_CHECK} )
set_tests_properties( Cppcheck
PROPERTIES FAIL_REGULAR_EXPRESSION "error file=" )
endif( TubeTK_USE_CPPCHECK )
if( TubeTK_USE_QT )
if( TubeTK_USE_CTK )
find_package( CTK REQUIRED )
include( ${CTK_USE_FILE} )
endif( TubeTK_USE_CTK )
endif( TubeTK_USE_QT )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
find_package( JsonCpp REQUIRED )
include_directories( ${JsonCpp_INCLUDE_DIRS} )
if( TubeTK_USE_KWSTYLE )
find_package( KWStyle REQUIRED )
find_package( Git )
if( GIT_FOUND )
execute_process( COMMAND ${GIT_EXECUTABLE} config hooks.KWStyle.path
"${KWSTYLE_EXECUTABLE}"
WORKING_DIRECTORY ${TubeTK_SOURCE_DIR} )
endif( GIT_FOUND )
option( KWSTYLE_USE_VIM_FORMAT
"Set KWStyle to generate errors in a Vim compatible format." OFF )
mark_as_advanced( KWSTYLE_USE_VIM_FORMAT )
option( KWSTYLE_USE_MSVC_FORMAT
"Set KWStyle to generate errors in a Microsoft Visual Studio compatible format."
OFF )
mark_as_advanced( KWSTYLE_USE_MSVC_FORMAT )
option( KWSTYLE_DASHBOARD_SUBMISSION
"Set the KWStyle arguments to generate a report for CDash dashboard submission."
OFF )
mark_as_advanced( KWSTYLE_DASHBOARD_SUBMISSION )
if( KWSTYLE_DASHBOARD_SUBMISSION )
set( KWSTYLE_ARGUMENTS -lesshtml
-xml ${TubeTK_BINARY_DIR}/KWStyle.kws.xml
-o ${TubeTK_BINARY_DIR}/KWStyle.Overwrite.txt
-dart ${TubeTK_BINARY_DIR} -1 1
-D ${TubeTK_BINARY_DIR}/KWStyle.Files.txt )
else( KWSTYLE_DASHBOARD_SUBMISSION )
set( KWSTYLE_ARGUMENTS -xml ${TubeTK_BINARY_DIR}/KWStyle.kws.xml
-v -o ${TubeTK_BINARY_DIR}/KWStyle.Overwrite.txt
-D ${TubeTK_BINARY_DIR}/KWStyle.Files.txt )
endif( KWSTYLE_DASHBOARD_SUBMISSION )
if( KWSTYLE_USE_VIM_FORMAT )
set( KWSTYLE_ARGUMENTS -vim ${KWSTYLE_ARGUMENTS} )
endif( KWSTYLE_USE_VIM_FORMAT )
if( KWSTYLE_USE_MSVC_FORMAT )
set( KWSTYLE_ARGUMENTS -msvc ${KWSTYLE_ARGUMENTS} )
endif( KWSTYLE_USE_MSVC_FORMAT )
configure_file( ${TubeTK_SOURCE_DIR}/CMake/KWStyle/KWStyle.kws.xml.in
${TubeTK_BINARY_DIR}/KWStyle.kws.xml )
configure_file( ${TubeTK_SOURCE_DIR}/CMake/KWStyle/KWStyle.Files.txt.in
${TubeTK_BINARY_DIR}/KWStyle.Files.txt )
configure_file( ${TubeTK_SOURCE_DIR}/CMake/KWStyle/KWStyle.Overwrite.txt.in
${TubeTK_BINARY_DIR}/KWStyle.Overwrite.txt )
add_custom_target( StyleCheck
COMMAND ${KWSTYLE_EXECUTABLE} ${KWSTYLE_ARGUMENTS}
WORKING_DIRECTORY ${TubeTK_BINARY_DIR}
COMMENT "Coding style checker" VERBATIM )
endif( TubeTK_USE_KWSTYLE )
if( TubeTK_USE_LIBSVM )
find_package( LIBSVM REQUIRED )
endif( TubeTK_USE_LIBSVM )
find_package( ParameterSerializer REQUIRED )
include_directories( ${ParameterSerializer_INCLUDE_DIRS} )
set( SlicerExecutionModel_CLI_RUNTIME_INSTALL_DIRECTORY
${TubeTK_INSTALL_BIN_DIR} )
set( SlicerExecutionModel_CLI_LIBRARY_INSTALL_DIRECTORY
${TubeTK_INSTALL_LIB_DIR} )
set( SlicerExecutionModel_CLI_INCLUDE_INSTALL_DIRECTORY
${TubeTK_INSTALL_INCLUDE_DIR} )
set( SlicerExecutionModel_CLI_SHARE_INSTALL_DIRECTORY
${TubeTK_INSTALL_SHARE_DIR} )
set( SlicerExecutionModel_CLI_ARCHIVE_INSTALL_DIRECTORY
${TubeTK_INSTALL_LIB_DIR} )
set( SlicerExecutionModel_CLI_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bin" )
set( SlicerExecutionModel_CLI_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/lib/TubeTK" )
set( SlicerExecutionModel_CLI_INCLUDE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/include/TubeTK" )
set( SlicerExecutionModel_CLI_SHARE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/share/TubeTK" )
set( SlicerExecutionModel_CLI_ARCHIVE_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/lib/TubeTK" )
find_package( SlicerExecutionModel REQUIRED GenerateCLP )
include( ${GenerateCLP_USE_FILE} )
if( TubeTK_USE_VTK )
find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
endif( TubeTK_USE_VTK )
# Check endianness.
include( TestBigEndian )
test_big_endian( CMAKE_WORDS_BIGENDIAN )
# Setup to conform to 3D Slicer paths and define plugin copying macros.
if( TubeTK_BUILD_MODULES AND NOT TubeTK_USE_SLICER )
include( Slicer4MacroGetSource )
Slicer4MacroGetSource( Resources )
Slicer4MacroGetSource( Base/CLI )
Slicer4MacroGetSource( Libs/ITKFactoryRegistration )
Slicer4MacroGetCLISource( ExpertAutomatedRegistration )
# Build ITKFactorRegistration
include( Slicer4Config )
set( CXX_TEST_PATH ${TubeTK_BINARY_DIR}/${Slicer4_INSTALL_BIN_DIR} )
set( LAUNCH_EXE "" )
set( SUPPORT_2D_IMAGES on )
set( ITKFactoryRegistration_INSTALL_BIN_DIR ${TubeTK_INSTALL_BIN_DIR} )
set( ITKFactoryRegistration_INSTALL_LIB_DIR ${TubeTK_INSTALL_LIB_DIR} )
add_subdirectory( ${TubeTK_SLICER_SOURCE_DIR}/Libs/ITKFactoryRegistration
${TubeTK_SLICER_BINARY_DIR}/Libs/ITKFactoryRegistration )
include_directories( ${Slicer_BINARY_DIR}/Libs/itkFactoryRegistration )
# Build SlicerBaseCLI
add_subdirectory( ${TubeTK_SLICER_SOURCE_DIR}/Base/CLI
${TubeTK_SLICER_BINARY_DIR}/Base/CLI )
# Config SlicerExecutionModel
set( extras ITKFactoryRegistration )
if( TubeTK_USE_VTK )
list( APPEND extras SlicerBaseCLI )
endif( TubeTK_USE_VTK )
set( SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES
${extras}
CACHE INTERNAL "3D Slicer execution model extra libraries." FORCE )
endif( TubeTK_BUILD_MODULES AND NOT TubeTK_USE_SLICER )
include( TubeTKMacroInstallPlugins )
# Setup Python VirtualEnv for testing.
if( BUILD_TESTING AND TubeTK_USE_PYTHON )
include( CMake/TubeTKVirtualEnvSetup.cmake )
endif( BUILD_TESTING AND TubeTK_USE_PYTHON )
# Test TubeTK IPython examples.
if( TubeTK_USE_NOTEBOOKS )
add_subdirectory( Examples )
endif( TubeTK_USE_NOTEBOOKS )
add_subdirectory( Utilities )
add_subdirectory( Base )
if( TubeTK_BUILD_MODULES )
add_subdirectory( Applications )
endif( TubeTK_BUILD_MODULES )
# Optionally build 3D Slicer modules.
if( TubeTK_BUILD_MODULES AND TubeTK_USE_SLICER )
add_subdirectory( SlicerModules )
endif( TubeTK_BUILD_MODULES AND TubeTK_USE_SLICER )
# Create the directory where CTest unit tests store temporary results.
make_directory( ${TubeTK_BINARY_DIR}/Temporary )
# Configure variables to export.
set( TubeTK_INCLUDE_DIRS
${TubeTK_SOURCE_DIR}/Base/CLI
${TubeTK_SOURCE_DIR}/Base/Common
${TubeTK_SOURCE_DIR}/Base/Filtering
${TubeTK_SOURCE_DIR}/Base/IO
${TubeTK_SOURCE_DIR}/Base/Numerics
${TubeTK_SOURCE_DIR}/Base/ObjectDocuments
${TubeTK_SOURCE_DIR}/Base/Registration
${TubeTK_SOURCE_DIR}/Base/Segmentation
${TubeTK_SOURCE_DIR}/Base/USTK )
if( MSVC )
set( TubeTK_EXECUTABLE_DIRS
${JsonCpp_DIR}/bin/${CMAKE_BUILD_TYPE}
${ParameterSerializer_DIR}/bin/${CMAKE_BUILD_TYPE}
${GenerateCLP_DIR}/${CMAKE_BUILD_TYPE}
${ITK_DIR}/bin/${CMAKE_BUILD_TYPE}
${TubeTK_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
${TubeTK_BINARY_DIR}/lib/TubeTK/Plugins/${CMAKE_BUILD_TYPE} )
if( TubeTK_USE_VTK )
list( APPEND TubeTK_EXECUTABLE_DIRS
${VTK_DIR}/bin/${CMAKE_BUILD_TYPE} )
endif( TubeTK_USE_VTK )
else( MSVC )
set( TubeTK_EXECUTABLE_DIRS
${JsonCpp_DIR}/bin
${ParameterSerializer_DIR}/bin
${GenerateCLP_DIR}
${ITK_DIR}/bin
${TubeTK_BINARY_DIR}/bin
${TubeTK_BINARY_DIR}/lib
${TubeTK_BINARY_DIR}/lib/TubeTK/Plugins )
if( TubeTK_USE_VTK )
list( APPEND ${VTK_DIR}/bin )
endif( TubeTK_USE_VTK )
endif( MSVC )
set( TubeTK_LIBRARY_DIRS
${TubeTK_EXECUTABLE_DIRS} )
# Configure TubeTKTargets.cmake.
get_property( TubeTK_TARGETS GLOBAL PROPERTY TubeTK_TARGETS )
export( TARGETS ${TubeTK_TARGETS} FILE ${TubeTK_CONFIG_BINARY_DIR}/TubeTKTargets.cmake )
set( TubeTK_TARGETS_FILE
${TubeTK_CONFIG_BINARY_DIR}/TubeTKTargets.cmake )
set( TubeTK_USE_FILE
${TubeTK_CONFIG_BINARY_DIR}/UseTubeTK.cmake )
# Configure TubeTKConfig.cmake.
# The variables set above are for building against a TubeTK build tree.
# A different TubeTKConfig.cmake will need to be generated in order to build
# against a TubeTK installation.
configure_file( ${TubeTK_SOURCE_DIR}/CMake/TubeTKConfig.cmake.in
${TubeTK_CONFIG_BINARY_DIR}/TubeTKConfig.cmake @ONLY )
# Configure UseTubeTK.cmake.
configure_file( ${TubeTK_SOURCE_DIR}/CMake/UseTubeTK.cmake.in
${TubeTK_CONFIG_BINARY_DIR}/UseTubeTK.cmake @ONLY )
# Configure a launcher for running TubeTK methods from the command line in
# Microsoft Windows.
configure_file( ${TubeTK_SOURCE_DIR}/CMake/TubeTKLauncher.bat.in
${TubeTK_BINARY_DIR}/TubeTKLauncher.bat @ONLY )
# Configure a launcher for running TubeTK methods from the command line in
# Apple OS X, Linux, or UNIX.
configure_file( ${TubeTK_SOURCE_DIR}/CMake/TubeTKLauncher.sh.in
${TubeTK_BINARY_DIR}/TubeTKLauncher.sh @ONLY )
# Configure CPack packaging.
if( NOT TubeTK_BUILD_SLICER_EXTENSION )
# Record ITK, VTK, CTK, and GenerateCLP libraries used by TubeTK for
# packaging.
file( GLOB_RECURSE ITK_BINARIES "${ITK_DIR}/lib/lib*" )
if( TubeTK_USE_VTK )
file( GLOB_RECURSE VTK_BINARIES "${VTK_DIR}/bin/lib*" )
endif( TubeTK_USE_VTK )
if( TubeTK_USE_CTK )
file( GLOB_RECURSE CTK_BINARIES "${CTK_DIR}/CTK-build/bin/lib*" )
endif( TubeTK_USE_CTK )
file( GLOB_RECURSE SEM_BINARIES "${GenerateCLP_DIR}/bin/lib*" )
file( GLOB_RECURSE JsonCpp_BINARIES "${JsonCpp_DIR}/lib/lib*" )
list( APPEND TubeTK_SUPPORT_BINARIES
${SEM_BINARIES} ${CTK_BINARIES} ${VTK_BINARIES} ${ITK_BINARIES}
${JsonCpp_BINARIES} )
install( FILES ${TubeTK_SUPPORT_BINARIES}
DESTINATION lib )
# Record the environment setup files for packaging.
set( TubeTK_LINUX_SETUP
${TubeTK_SOURCE_DIR}/CMake/TubeTKSourceMeToSetupLinux.sh )
set( TubeTK_WINDOWS_SETUP
${TubeTK_SOURCE_DIR}/CMake/TubeTKRunMeToSetupWindows.bat )
include( InstallRequiredSystemLibraries )
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY
"TubeTK for the analysis of geometric structures in images." )
set( CPACK_PACKAGE_VENDOR "Kitware, Inc." )
set( CPACK_PACKAGE_DESCRIPTION_FILE "${TubeTK_SOURCE_DIR}/CMake/CPack/DESCRIPTION.txt" )
set( CPACK_RESOURCE_FILE_LICENSE "${TubeTK_SOURCE_DIR}/CMake/CPack/LICENSE.txt" )
set( CPACK_PACKAGE_VERSION_MAJOR ${TubeTK_VERSION_MAJOR} )
set( CPACK_PACKAGE_VERSION_MINOR ${TubeTK_VERSION_MINOR} )
set( CPACK_PACKAGE_VERSION_PATCH ${TubeTK_VERSION_PATCH} )
set( CPACK_PACKAGE_VERSION ${TubeTK_VERSION_BUILD} )
set( CPACK_PACKAGE_CONTACT "stephen.aylward@kitware.com" )
set( CPACK_PACKAGE_INSTALL_DIRECTORY
"TubeTK_${TubeTK_VERSION_MAJOR}.${TubeTK_VERSION_MINOR}" )
if( WIN32 AND NOT UNIX )
# There is a bug in NSI that does not handle full UNIX paths properly. Make
# sure there is at least one set of four backslashes.
set( CPACK_PACKAGE_ICON
"${TubeTK_SOURCE_DIR}\\\\Icon.png" )
set( CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\TubeTK.exe" )
set( CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} TubeTK" )
set( CPACK_NSIS_HELP_LINK "http:\\\\\\\\tubetk.org" )
set( CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\tubetk.org" )
set( CPACK_NSIS_CONTACT "stephen.aylward@kitware.com" )
set( CPACK_NSIS_MODIFY_PATH ON )
else( WIN32 AND NOT UNIX )
set( CPACK_STRIP_FILES true )
set( CPACK_SOURCE_STRIP_FILES true )
endif( WIN32 AND NOT UNIX )
set( CMAKE_INSTALL_RPATH "$ORIGIN/../..;." )
# Standard CPack setup.
option( CMAKE_INSTALL_DEBUG_LIBRARIES
"Install the Microsoft runtime debug libraries with CMake." FALSE )
mark_as_advanced( CMAKE_INSTALL_DEBUG_LIBRARIES )
# By default, do not warn when built on machines using only Microsoft Visual
# Studio Express.
if( NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS )
set( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON )
endif( NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS )
# Make this explicit here, rather than accepting the CPack default value, so
# we can refer to it.
set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}" )
# Installers for 32- vs. 64-bit CMake:
# - Root install directory (displayed to end user at installer runtime).
# - NSIS package/display name (text used in the installer GUI).
# - Registry key used to store information about the installation.
if( CMAKE_CL_64 )
set( CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64" )
set( CPACK_NSIS_PACKAGE_NAME
"${CPACK_PACKAGE_INSTALL_DIRECTORY} ( Win64 )" )
set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} ( Win64 )" )
else( CMAKE_CL_64 )
set( CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES" )
set( CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}" )
set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}" )
endif( CMAKE_CL_64 )
if( NOT DEFINED CPACK_SYSTEM_NAME )
set( CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR} )
endif( NOT DEFINED CPACK_SYSTEM_NAME )
if( ${CPACK_SYSTEM_NAME} MATCHES Windows )
if( CMAKE_CL_64 )
set( CPACK_SYSTEM_NAME win64-x64 )
else( CMAKE_CL_64 )
set( CPACK_SYSTEM_NAME win32-x86 )
endif( CMAKE_CL_64 )
endif( ${CPACK_SYSTEM_NAME} MATCHES Windows )
set( CPACK_SOURCE_PACKAGE_FILE_NAME "TubeTK-${TubeTK_VERSION_BUILD}" )
set( CPACK_PACKAGE_FILE_NAME
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}" )
# Include CPack model once all variables are set.
include( CPack )
else( NOT TubeTK_BUILD_SLICER_EXTENSION )
include( ${Slicer_EXTENSION_CPACK} )
endif( NOT TubeTK_BUILD_SLICER_EXTENSION )