-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1318 lines (1134 loc) · 53.6 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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.16.3...3.19.7 FATAL_ERROR)
if("${CMAKE_VERSION}" VERSION_EQUAL "3.21.0")
message(FATAL_ERROR "CMake version is ${CMAKE_VERSION} and using CMake==3.21.0 is not supported.\nSee https://gitlab.kitware.com/cmake/cmake/-/issues/22476")
endif()
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.25.0" AND "${CMAKE_VERSION}" VERSION_LESS_EQUAL "3.25.2")
message(FATAL_ERROR "CMake version is ${CMAKE_VERSION} and using CMake >=3.25.0,<=3.25.2 is not supported.\nSee https://gitlab.kitware.com/cmake/cmake/-/issues/24567")
endif()
#-----------------------------------------------------------------------------
# Setting C++ Standard
#-----------------------------------------------------------------------------
set(_msg "Setting C++ standard")
message(STATUS "${_msg}")
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "${_msg} - C++${CMAKE_CXX_STANDARD}")
if(NOT CMAKE_CXX_STANDARD MATCHES "^(17|20)$")
message(FATAL_ERROR "CMAKE_CXX_STANDARD must be set to 17 or 20")
endif()
# Prevent unnecessary re-linking on Linux
#
# See https://discourse.slicer.org/t/build-when-git-commit-is-changed/29607/12
#
# For example, on Linux, after modifying one implementation file
#
# $ touch ../../Slicer/Libs/MRML/Core/vtkMRMLScene.cxx
#
# We can observe that beside the rebuilding of libMRMLCore.so no relinking
# happen for any of the dependencies:
#
# $ make -j10
# [...]
# [ 24%] Building CXX object Libs/MRML/Core/CMakeFiles/MRMLCore.dir/vtkMRMLScene.cxx.o
# [ 24%] Linking CXX shared library ../../../bin/libMRMLCore.so
# [ 26%] Built target MRMLCore
# [ 26%] Built target MRMLCLI
# [...]
# [100%] Built target qSlicerVolumeRenderingModuleCxxTests
#
if(NOT DEFINED CMAKE_LINK_DEPENDS_NO_SHARED AND UNIX AND NOT APPLE)
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
endif()
#-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
set(SUPERBUILD_TOPLEVEL_PROJECT Slicer)
list(APPEND EXTERNAL_PROJECT_ADDITIONAL_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild)
include(ExternalProject)
include(ExternalProjectDependency)
include(ExternalProjectDependencyForPython)
include(ExternalProjectGenerateProjectDescription)
#-----------------------------------------------------------------------------
if(APPLE)
# Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
# we ensure that the bitness, and C++ standard library will be properly detected.
include(SlicerInitializeOSXVariables)
mark_as_superbuild(
VARS CMAKE_OSX_ARCHITECTURES:STRING CMAKE_OSX_SYSROOT:PATH CMAKE_OSX_DEPLOYMENT_TARGET:STRING
ALL_PROJECTS
)
set(CMAKE_INSTALL_NAME_TOOL "" CACHE FILEPATH "" FORCE)
# Due to the possibility of external projects (e.g., LibFFI) enabling languages (e.g., ASM)
# that necessitate `install_name_tool` via the "CMakeFindBinUtils" module, we opt to clear
# CMAKE_INSTALL_NAME_TOOL on a per-project basis.
# mark_as_superbuild(VARS CMAKE_INSTALL_NAME_TOOL:FILEPATH ALL_PROJECTS)
set(CMAKE_MACOSX_RPATH 0)
mark_as_superbuild(VARS CMAKE_MACOSX_RPATH:BOOL ALL_PROJECTS)
endif()
#-----------------------------------------------------------------------------
if(NOT DEFINED Slicer_VERSION_MAJOR)
set(Slicer_VERSION_MAJOR "5")
endif()
if(NOT DEFINED Slicer_VERSION_MINOR)
set(Slicer_VERSION_MINOR "7")
endif()
if(NOT DEFINED Slicer_VERSION_PATCH)
set(Slicer_VERSION_PATCH "0")
endif()
project(Slicer VERSION "${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}.${Slicer_VERSION_PATCH}")
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${Slicer_SOURCE_DIR}/Extensions/CMake
${CMAKE_MODULE_PATH}
)
set(Slicer_CMAKE_DIR ${Slicer_SOURCE_DIR}/CMake)
set(Slicer_EXTENSIONS_CMAKE_DIR ${Slicer_SOURCE_DIR}/Extensions/CMake)
#-----------------------------------------------------------------------------
# https://www.slicer.org/w/index.php/Documentation/Nightly/Developers/DevelopmentWithGit
#-----------------------------------------------------------------------------
include(SlicerCheckSourceTree)
#-----------------------------------------------------------------------------
# Superbuild Option - Enabled by default
#-----------------------------------------------------------------------------
option(Slicer_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON)
mark_as_advanced(Slicer_SUPERBUILD)
set(Slicer_BINARY_INNER_SUBDIR Slicer-build)
#-----------------------------------------------------------------------------
include(CTestUseLaunchers OPTIONAL)
if(${CTEST_USE_LAUNCHERS})
message(STATUS "CTest launchers enabled")
endif()
#-----------------------------------------------------------------------------
# Sanity checks
#------------------------------------------------------------------------------
if(WIN32)
set(${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH 40)
if(NOT ${PROJECT_NAME}_SUPERBUILD)
string(LENGTH ${Slicer_BINARY_INNER_SUBDIR} _inner_subdir_length)
math(EXPR ${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH "${${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH} + ${_inner_subdir_length}")
endif()
include(PreventDirWithTooManyChars)
endif()
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)
include(PreventDirWithSpaces)
mark_as_superbuild(${PROJECT_NAME}_SKIP_DIR_WITH_SPACES_CHECK:BOOL)
#-----------------------------------------------------------------------------
# Overwrite default options
#-----------------------------------------------------------------------------
set(_overwrite_options_file ${Slicer_CMAKE_DIR}/SlicerOverwriteDefaultOptions.cmake)
if(EXISTS ${_overwrite_options_file})
include(${_overwrite_options_file})
endif()
#-----------------------------------------------------------------------------
# Check if the linker will resolve symbols of underlinked libraries
#-----------------------------------------------------------------------------
if(UNIX AND NOT APPLE)
include(SlicerLinkerAsNeededFlagCheck)
if(Slicer_LINKER_NO_AS_NEEDED_FLAG_REQUIRED)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed"
CACHE STRING "Flags used by the linker"
FORCE)
endif()
endif()
#-----------------------------------------------------------------------------
# Slicer Build and Release type
#-----------------------------------------------------------------------------
include(SlicerInitializeBuildType)
include(SlicerInitializeReleaseType)
#-----------------------------------------------------------------------------
# Set the header template which defines custom export/import macros
# for shared libraries
#-----------------------------------------------------------------------------
set(Slicer_EXPORT_HEADER_TEMPLATE "${Slicer_SOURCE_DIR}/CMake/qSlicerExport.h.in")
set(Slicer_LOGOS_RESOURCE "${Slicer_SOURCE_DIR}/Resources/qSlicer.qrc")
#-----------------------------------------------------------------------------
# Platform checks
#-----------------------------------------------------------------------------
include(SlicerBlockPlatformCheck)
mark_as_superbuild(Slicer_PLATFORM_CHECK:BOOL)
#-----------------------------------------------------------------------------
# Determine endian type
#-----------------------------------------------------------------------------
include(TestBigEndian)
test_big_endian(CMAKE_WORDS_BIGENDIAN)
#-----------------------------------------------------------------------------
# Prerequisites
#-----------------------------------------------------------------------------
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "error: Install Git and try to re-configure")
endif()
mark_as_superbuild(GIT_EXECUTABLE)
find_package(Patch REQUIRED)
mark_as_superbuild(Patch_EXECUTABLE)
#-----------------------------------------------------------------------------
# Qt requirements
#-----------------------------------------------------------------------------
if(NOT DEFINED Slicer_REQUIRED_QT_VERSION)
# Official builds and tests are performed with Qt-5.15 on all platforms,
# but since it is not easy to get latest Qt versions on Linux, the version
# requirement is relaxed on Linux so that it builds on Ubuntu-20.04.
# See https://github.com/Slicer/Slicer/issues/5804 for more details.
if(UNIX AND NOT APPLE)
# Linux
set(_required_qt_version "5.12")
else()
# Windows and macOS
set(_required_qt_version "5.15")
endif()
set(Slicer_REQUIRED_QT_VERSION ${_required_qt_version} CACHE STRING "Minimum required Qt version" FORCE)
endif()
mark_as_superbuild(Slicer_REQUIRED_QT_VERSION)
#-----------------------------------------------------------------------------
# Python requirements
#-----------------------------------------------------------------------------
if(NOT DEFINED Slicer_REQUIRED_PYTHON_VERSION)
set(Slicer_REQUIRED_PYTHON_VERSION "3.9.10")
endif()
mark_as_superbuild(Slicer_REQUIRED_PYTHON_VERSION)
if(NOT Slicer_REQUIRED_PYTHON_VERSION MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
message(FATAL_ERROR "Slicer_REQUIRED_PYTHON_VERSION [${Slicer_REQUIRED_PYTHON_VERSION}] is invalid. Value expected to be formatted as X.Y.Z")
endif()
set(Slicer_REQUIRED_PYTHON_VERSION_MAJOR ${CMAKE_MATCH_1})
set(Slicer_REQUIRED_PYTHON_VERSION_MINOR ${CMAKE_MATCH_2})
set(Slicer_REQUIRED_PYTHON_VERSION_PATCH ${CMAKE_MATCH_3})
set(Slicer_REQUIRED_PYTHON_VERSION_DOT ${Slicer_REQUIRED_PYTHON_VERSION_MAJOR}.${Slicer_REQUIRED_PYTHON_VERSION_MINOR})
set(Slicer_REQUIRED_PYTHON_ABIFLAGS "")
if(Slicer_REQUIRED_PYTHON_VERSION_DOT VERSION_LESS "3.8")
set(Slicer_REQUIRED_PYTHON_ABIFLAGS "m")
endif()
#-----------------------------------------------------------------------------
# Build shared lib by default
#------------------------------------------------------------------------------
# option(BUILD_SHARED_LIBS "Build Slicer with shared libraries." ON)
set(BUILD_SHARED_LIBS ON)
mark_as_superbuild(BUILD_SHARED_LIBS:BOOL)
set(Slicer_BUILD_SHARED ${BUILD_SHARED_LIBS})
#-----------------------------------------------------------------------------
# Slicer application options
#-----------------------------------------------------------------------------
include(SlicerApplicationOptions)
#-----------------------------------------------------------------------------
# Append the library version information to the library target properties.
#------------------------------------------------------------------------------
option(Slicer_WITH_LIBRARY_VERSION "Build with library version information" OFF)
mark_as_advanced(Slicer_WITH_LIBRARY_VERSION)
mark_as_superbuild(Slicer_WITH_LIBRARY_VERSION)
if(Slicer_WITH_LIBRARY_VERSION)
set(Slicer_LIBRARY_PROPERTIES ${Slicer_LIBRARY_PROPERTIES}
VERSION ${Slicer_VERSION_FULL}
SOVERSION ${Slicer_VERSION}
)
endif()
#-----------------------------------------------------------------------------
# General Slicer Options
#-----------------------------------------------------------------------------
include(CMakeDependentOption)
option(BUILD_TESTING "Test the project" ON)
mark_as_superbuild(BUILD_TESTING)
#option(WITH_MEMCHECK "Run tests through valgrind." OFF)
#mark_as_superbuild(WITH_MEMCHECK)
option(WITH_COVERAGE "Enable/Disable coverage" OFF)
mark_as_superbuild(WITH_COVERAGE)
option(Slicer_USE_VTK_DEBUG_LEAKS "Enable VTKs Debug Leaks functionality in both VTK and Slicer." ON)
mark_as_superbuild(Slicer_USE_VTK_DEBUG_LEAKS:BOOL)
set(VTK_DEBUG_LEAKS ${Slicer_USE_VTK_DEBUG_LEAKS})
option(Slicer_BUILD_DICOM_SUPPORT "Build Slicer with DICOM support" ON)
mark_as_superbuild(Slicer_BUILD_DICOM_SUPPORT)
option(Slicer_BUILD_DIFFUSION_SUPPORT "Build Slicer with diffusion (DWI, DTI) support" ON)
mark_as_superbuild(Slicer_BUILD_DIFFUSION_SUPPORT)
option(Slicer_BUILD_I18N_SUPPORT "Build Slicer with Internationalization support" ON)
mark_as_superbuild(Slicer_BUILD_I18N_SUPPORT)
option(Slicer_BUILD_USAGE_LOGGING_SUPPORT "Build Slicer with support for software usage logging" ON)
mark_as_superbuild(Slicer_BUILD_USAGE_LOGGING_SUPPORT)
option(Slicer_BUILD_WEBENGINE_SUPPORT "Build Slicer with Qt WebEngine support" ON)
mark_as_superbuild(Slicer_BUILD_WEBENGINE_SUPPORT)
option(Slicer_BUILD_QTLOADABLEMODULES "Build Slicer Qt Loadable Modules" ON)
mark_as_advanced(Slicer_BUILD_QTLOADABLEMODULES)
mark_as_superbuild(Slicer_BUILD_QTLOADABLEMODULES)
option(Slicer_USE_PYTHONQT "Integrate a Python-Qt interpreter into Slicer." ON)
mark_as_superbuild(Slicer_USE_PYTHONQT)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_QTSCRIPTEDMODULES "Build Slicer Python Qt Modules" ON
"Slicer_USE_PYTHONQT" OFF)
mark_as_advanced(Slicer_BUILD_QTSCRIPTEDMODULES)
mark_as_superbuild(Slicer_BUILD_QTSCRIPTEDMODULES)
option(Slicer_BUILD_CLI_SUPPORT "Build Slicer with CLI support" ON)
mark_as_superbuild(Slicer_BUILD_CLI_SUPPORT)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_CLI "Build Slicer CLI Plugins" ON
"Slicer_BUILD_CLI_SUPPORT" OFF
)
mark_as_superbuild(Slicer_BUILD_CLI)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_LEGACY_CLI "Build Slicer LEGACY_CLI Plugins" ON
"Slicer_BUILD_CLI" OFF
)
option(Slicer_BUILD_QT_DESIGNER_PLUGINS "Build Qt designer plugins" ON)
mark_as_superbuild(Slicer_BUILD_QT_DESIGNER_PLUGINS)
option(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT "Build Slicer extensions manager" ON)
mark_as_superbuild(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT)
option(Slicer_BUILD_APPLICATIONUPDATE_SUPPORT "Build Slicer with application update support" ON)
mark_as_superbuild(Slicer_BUILD_APPLICATIONUPDATE_SUPPORT)
option(Slicer_BUILD_MULTIMEDIA_SUPPORT "Build Slicer with Multimedia support" ON)
mark_as_superbuild(Slicer_BUILD_MULTIMEDIA_SUPPORT)
CMAKE_DEPENDENT_OPTION(Slicer_UPDATE_TRANSLATION "update translation" OFF "Slicer_BUILD_I18N_SUPPORT" OFF)
mark_as_advanced(Slicer_UPDATE_TRANSLATION)
mark_as_superbuild(Slicer_UPDATE_TRANSLATION)
set(Slicer_FORCED_WC_LAST_CHANGED_DATE "" CACHE STRING "Overwrite value of auto-discovered Slicer_WC_LAST_CHANGED_DATE (format: YYYY-MM-DD)")
mark_as_advanced(Slicer_FORCED_WC_LAST_CHANGED_DATE)
mark_as_superbuild(Slicer_FORCED_WC_LAST_CHANGED_DATE)
set(Slicer_FORCED_REVISION "" CACHE STRING "Overwrite value of automatically set Slicer_REVISION")
mark_as_advanced(Slicer_FORCED_REVISION)
mark_as_superbuild(Slicer_FORCED_REVISION)
set(Slicer_REVISION_TYPE "CommitCount" CACHE STRING "How to set Slicer_REVISION - from commit count or git hash." FORCE)
set_property(CACHE Slicer_REVISION_TYPE PROPERTY STRINGS
"CommitCount"
"Hash"
)
mark_as_advanced(Slicer_REVISION_TYPE)
mark_as_superbuild(Slicer_REVISION_TYPE)
# Default Slicer_WC_COMMIT_COUNT_OFFSET
set(_commit_count_offsets
# Value is chosen to provide continuity of revisions when switching from SVN to git
# at SVN revision=28825 / git hash 47deb76d7556e40de4e25e585c4b24a63a153da5 in official Slicer repository
# (https://github.com/Slicer/Slicer.git).
"3037"
# Allocate revisions for patch releases between v5.0.0 and v5.1.0
"100"
# Allocate revisions for patch releases between v5.2.0 and v5.3.0
"100"
# Allocate revisions for patch releases between v5.4.0 and v5.5.0
"200"
# Allocate revisions for patch releases between v5.6.0 and v5.7.0
"200"
)
list(JOIN _commit_count_offsets "+" _commit_count_offsets_expr)
math(EXPR _commit_count_offset "${_commit_count_offsets_expr}")
set(Slicer_WC_COMMIT_COUNT_OFFSET "${_commit_count_offset}" CACHE INTERNAL
"This value is added to commit count to compute Slicer_COMMIT_COUNT (that may be used to set Slicer_REVISION).")
mark_as_advanced(Slicer_WC_COMMIT_COUNT_OFFSET)
mark_as_superbuild(Slicer_WC_COMMIT_COUNT_OFFSET)
option(Slicer_USE_FOLDERS "Organize build targets into folders" ON)
mark_as_superbuild(Slicer_USE_FOLDERS)
mark_as_advanced(Slicer_USE_FOLDERS)
#-----------------------------------------------------------------------------
# Slicer version number
#-----------------------------------------------------------------------------
include(SlicerVersion)
#-----------------------------------------------------------------------------
# External projects related options
#-----------------------------------------------------------------------------
CMAKE_DEPENDENT_OPTION(
Slicer_USE_PYTHONQT_WITH_OPENSSL "Enable PythonQt SSL support" ON
"Slicer_USE_PYTHONQT" OFF)
mark_as_superbuild(Slicer_USE_PYTHONQT_WITH_OPENSSL)
CMAKE_DEPENDENT_OPTION(
Slicer_USE_NUMPY "Build Slicer with NumPy" ON
"Slicer_USE_PYTHONQT" OFF)
mark_as_superbuild(Slicer_USE_NUMPY)
CMAKE_DEPENDENT_OPTION(
Slicer_USE_SCIPY "Build Slicer with SciPy" ON
"Slicer_USE_PYTHONQT;Slicer_USE_NUMPY" OFF)
mark_as_superbuild(Slicer_USE_SCIPY)
option(Slicer_USE_CTKAPPLAUNCHER "Configure ctkAppLauncher." ON)
mark_as_advanced(Slicer_USE_CTKAPPLAUNCHER)
mark_as_superbuild(Slicer_USE_CTKAPPLAUNCHER)
option(Slicer_USE_QtTesting "Integrate QtTesting framework into Slicer." ON)
mark_as_advanced(Slicer_USE_QtTesting)
mark_as_superbuild(Slicer_USE_QtTesting)
CMAKE_DEPENDENT_OPTION(
Slicer_USE_SimpleITK "Build Slicer with SimpleITK support" ON
"Slicer_USE_PYTHONQT" OFF)
mark_as_superbuild(Slicer_USE_SimpleITK)
option(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT "Build Slicer with parameter serializer support" OFF)
mark_as_superbuild(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT)
set(_default_vtk "9")
set(Slicer_VTK_VERSION_MAJOR ${_default_vtk} CACHE STRING "VTK major version (9)")
set_property(CACHE Slicer_VTK_VERSION_MAJOR PROPERTY STRINGS "9")
if(NOT "${Slicer_VTK_VERSION_MAJOR}" MATCHES "^(9)$")
message(FATAL_ERROR "error: Slicer_VTK_VERSION_MAJOR must be 9.")
endif()
mark_as_superbuild(Slicer_VTK_VERSION_MAJOR)
#
# SimpleITK has large internal libraries, which take an extremely long
# time to link on windows when they are static. Creating shared
# SimpleITK internal libraries can reduce linking time. Also the size
# of the debug libraries are monstrous. Using shared libraries for
# debug, reduce disc requirements, and can improve linking
# times. However, these shared libraries take longer to load than the
# monolithic target from static libraries.
#
set( Slicer_USE_SimpleITK_SHARED_DEFAULT OFF)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
if(MSVC OR _CMAKE_BUILD_TYPE MATCHES "DEBUG")
set(Slicer_USE_SimpleITK_SHARED_DEFAULT ON)
endif()
CMAKE_DEPENDENT_OPTION(Slicer_USE_SimpleITK_SHARED "Build SimpleITK with shared libraries. Reduces linking time, increases run-time load time." ${Slicer_USE_SimpleITK_SHARED_DEFAULT} "Slicer_USE_SimpleITK" OFF )
mark_as_superbuild(Slicer_USE_SimpleITK_SHARED)
#-----------------------------------------------------------------------------
# Install no development files by default, but allow the user to get
# them installed by setting Slicer_INSTALL_DEVELOPMENT to true.
#-----------------------------------------------------------------------------
option(Slicer_INSTALL_DEVELOPMENT "Install Slicer extension development files." OFF)
mark_as_advanced(Slicer_INSTALL_DEVELOPMENT)
if(NOT Slicer_INSTALL_DEVELOPMENT)
set(Slicer_INSTALL_NO_DEVELOPMENT 1)
else()
set(Slicer_INSTALL_NO_DEVELOPMENT 0)
endif()
#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
option(Slicer_BUILD_DOCUMENTATION "Build documentation (Doxygen, sphinx, ...)" ON)
mark_as_advanced(Slicer_BUILD_DOCUMENTATION)
mark_as_superbuild(Slicer_BUILD_DOCUMENTATION)
if(Slicer_BUILD_DOCUMENTATION)
find_package(Doxygen QUIET)
if(DOXYGEN_DOT_FOUND)
mark_as_superbuild(DOXYGEN_EXECUTABLE)
set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CACHE PATH "Where documentation archives should be stored")
mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
mark_as_superbuild(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)
mark_as_superbuild(DOCUMENTATION_TARGET_IN_ALL)
endif()
endif()
#-----------------------------------------------------------------------------
# CTestCustom
#-----------------------------------------------------------------------------
configure_file(
CMake/CTestCustom.cmake.in
${CMAKE_BINARY_DIR}/CTestCustom.cmake
COPYONLY
)
#-----------------------------------------------------------------------------
# Additional CXX/C Flags
#-----------------------------------------------------------------------------
set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
mark_as_advanced(ADDITIONAL_C_FLAGS)
set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
mark_as_advanced(ADDITIONAL_CXX_FLAGS)
#-----------------------------------------------------------------------------
# CMake Function(s) and Macro(s)
#-----------------------------------------------------------------------------
include(CMakeParseArguments)
include(SlicerMacroBuildScriptedCLI)
include(SlicerMacroBuildScriptedModule)
include(SlicerMacroGetOperatingSystemArchitectureBitness)
if(Slicer_BUILD_I18N_SUPPORT)
include(SlicerMacroTranslation)
endif()
include(SlicerFunctionInstallLibrary)
include(SlicerFunctionAddPythonQtResources)
set(Slicer_QRCC_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/Scripts/qrcc.py" CACHE INTERNAL "Path to qrcc.py script used in slicerFunctionAddPythonQtResources() CMake function")
#-----------------------------------------------------------------------------
# Internationalization
#-----------------------------------------------------------------------------
if(Slicer_BUILD_I18N_SUPPORT)
set(Slicer_LANGUAGES
"fr"
CACHE STRING "Semicolon separated list of supported Slicer languages. Expected format : language[_country] (both en and en_US are supported)."
)
mark_as_advanced(Slicer_LANGUAGES)
mark_as_superbuild(Slicer_LANGUAGES)
endif()
#-----------------------------------------------------------------------------
# Set Slicer_{C,CXX}_REQUIRED_FLAGS variables
#-----------------------------------------------------------------------------
include(SlicerBlockCXXRequiredFlags)
#-----------------------------------------------------------------------------
# Slicer directories
#-----------------------------------------------------------------------------
include(SlicerDirectories)
# SlicerExecutionModel output directories
if(Slicer_SUPERBUILD)
set(_sem_output_dir ${CMAKE_BINARY_DIR}/${Slicer_BINARY_INNER_SUBDIR})
else()
set(_sem_output_dir ${CMAKE_BINARY_DIR})
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY ${_sem_output_dir}/${Slicer_CLIMODULES_BIN_DIR})
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY ${_sem_output_dir}/${Slicer_CLIMODULES_LIB_DIR})
endif()
if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY)
set(SlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY ${_sem_output_dir}/${Slicer_CLIMODULES_LIB_DIR})
endif()
#-----------------------------------------------------------------------------
# Extension directories
#-----------------------------------------------------------------------------
# NOTE: Make sure to update vtkSlicerApplicationLogic::IsEmbeddedModule if
# the following variable is changed.
set(Slicer_EXTENSIONS_DIRBASENAME "Extensions")
#-----------------------------------------------------------------------------
# Slicer OpenGL Options
#-----------------------------------------------------------------------------
if(UNIX AND NOT APPLE)
set(OpenGL_GL_PREFERENCE "LEGACY")
mark_as_superbuild(OpenGL_GL_PREFERENCE:STRING)
endif()
#-----------------------------------------------------------------------------
# Slicer VTK Options
#-----------------------------------------------------------------------------
set(_backend "OpenGL2")
set(Slicer_VTK_RENDERING_BACKEND "${_backend}" CACHE STRING "Rendering backend." FORCE)
mark_as_superbuild(Slicer_VTK_RENDERING_BACKEND)
set(Slicer_VTK_RENDERING_USE_${Slicer_VTK_RENDERING_BACKEND}_BACKEND 1)
# Slicer build is only tested with Sequential and TBB. OpenMP might work.
set(Slicer_DEFAULT_VTK_SMP_IMPLEMENTATION_TYPE "TBB")
set(Slicer_VTK_SMP_IMPLEMENTATION_TYPE ${Slicer_DEFAULT_VTK_SMP_IMPLEMENTATION_TYPE}
CACHE STRING "Which multi-threaded parallelism implementation to use in VTK. Options are Sequential or TBB.")
set_property(CACHE Slicer_VTK_SMP_IMPLEMENTATION_TYPE
PROPERTY
STRINGS Sequential TBB)
mark_as_superbuild(Slicer_VTK_SMP_IMPLEMENTATION_TYPE)
if(${Slicer_VTK_SMP_IMPLEMENTATION_TYPE} STREQUAL "TBB")
set(Slicer_USE_TBB TRUE)
else()
set(Slicer_USE_TBB FALSE)
endif()
message(STATUS "Configuring VTK")
message(STATUS " Slicer_VTK_RENDERING_BACKEND is ${Slicer_VTK_RENDERING_BACKEND}")
message(STATUS " Slicer_VTK_SMP_IMPLEMENTATION_TYPE is ${Slicer_VTK_SMP_IMPLEMENTATION_TYPE}")
message(STATUS " Slicer_VTK_VERSION_MAJOR is ${Slicer_VTK_VERSION_MAJOR}")
#-----------------------------------------------------------------------------
# Slicer_VTK_COMPONENTS
#-----------------------------------------------------------------------------
set(Slicer_VTK_COMPONENTS
FiltersExtraction
FiltersFlowPaths
FiltersGeometry
FiltersParallel
GUISupportQtSQL
IOExport
IOImage
IOLegacy
IOPLY
IOXML
ImagingMath
ImagingMorphological
ImagingStatistics
ImagingStencil
InteractionImage
RenderingContext${Slicer_VTK_RENDERING_BACKEND}
RenderingQt
RenderingVolume${Slicer_VTK_RENDERING_BACKEND}
TestingRendering
ViewsQt
zlib
)
if(Slicer_USE_PYTHONQT)
list(APPEND Slicer_VTK_COMPONENTS
WrappingPythonCore
)
endif()
#-----------------------------------------------------------------------------
# Qt - Slicer_REQUIRED_QT_MODULES
#-----------------------------------------------------------------------------
# Module name should be specified as they appear in FindQt5.cmake.
# For example, the module name associated with the variable QT_USE_QTXML is QTXML.
# Note that the modules will be installed when packaging.
set(Slicer_REQUIRED_QT_MODULES
Core Widgets
Network OpenGL
PrintSupport
UiTools #no dll
Xml XmlPatterns
Svg Sql
)
if(Slicer_BUILD_MULTIMEDIA_SUPPORT)
list(APPEND Slicer_REQUIRED_QT_MODULES
Multimedia
MultimediaWidgets
)
endif()
# Add the Qt5X11Extras component for Linux systems
# This component is needed for building VTK
if(UNIX AND NOT APPLE)
list(APPEND Slicer_REQUIRED_QT_MODULES X11Extras)
endif()
find_package(Qt5 COMPONENTS Core QUIET)
if(Slicer_BUILD_WEBENGINE_SUPPORT)
list(APPEND Slicer_REQUIRED_QT_MODULES
WebEngine
WebEngineWidgets
WebChannel
)
endif()
# Both "extension manager" and "application update" require qRestApi external
# project itself depending on Qt's Qml module
if(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT OR Slicer_BUILD_APPLICATIONUPDATE_SUPPORT)
list(APPEND Slicer_REQUIRED_QT_MODULES Qml)
endif()
if(Slicer_BUILD_I18N_SUPPORT)
list(APPEND Slicer_REQUIRED_QT_MODULES LinguistTools) # no dll
endif()
if(BUILD_TESTING)
list(APPEND Slicer_REQUIRED_QT_MODULES Test)
endif()
list(APPEND Slicer_REQUIRED_QT_MODULES ${Slicer_ADDITIONAL_REQUIRED_QT_MODULES})
set(QT_LIBRARIES)
foreach(lib IN LISTS Slicer_REQUIRED_QT_MODULES)
if(lib MATCHES "^(LinguistTools)$")
continue()
endif()
list(APPEND QT_LIBRARIES Qt5::${lib})
endforeach()
if(DEFINED Slicer_ADDITIONAL_REQUIRED_QT_MODULES)
mark_as_superbuild(Slicer_ADDITIONAL_REQUIRED_QT_MODULES:STRING)
endif()
mark_as_superbuild(Slicer_USE_SYSTEM_QT:BOOL)
#-----------------------------------------------------------------------------
# Qt plugins (designer, imageformats, ...) relative directories
#-----------------------------------------------------------------------------
set(Slicer_QtPlugins_DIR "${CMAKE_INSTALL_LIBDIR}/QtPlugins")
set(Slicer_INSTALL_QtPlugins_DIR "${Slicer_INSTALL_ROOT}${Slicer_QtPlugins_DIR}")
#-----------------------------------------------------------------------------
# Qt
#-----------------------------------------------------------------------------
include(SlicerBlockFindQtAndCheckVersion)
mark_as_superbuild(VARS Qt5_DIR LABELS "FIND_PACKAGE")
set(Slicer_HAVE_QT5 1)
set(Slicer_HAVE_WEBKIT_SUPPORT 0)
#
# If qmake or Qt5Config are associated with a system location, explicitly mark Qt as such. Doing so
# will prevent system path from being prepended to PATH or (DY)LD_LIBRARY_PATH
# when generating the launcher settings and avoid system libraries symbols from
# conflicting with Slicer version of these libraries.
#
# See https://issues.slicer.org/view.php?id=3574
#
foreach(_path IN ITEMS
"/usr/lib/"
"/usr/lib32/"
"/usr/lib64/"
"/usr/local/lib/"
# homebrew
"/usr/local/Cellar/lib/"
# macport
"/opt/lib"
"/opt/local/lib"
)
if("${Qt5_DIR}" MATCHES "^${_path}")
set(Slicer_USE_SYSTEM_QT ON)
message(STATUS "")
message(STATUS "Forcing Slicer_USE_SYSTEM_QT to ON (Qt5_DIR [${Qt5_DIR}] associated with a system location: ${_path})")
message(STATUS "")
break()
endif()
endforeach()
# Always use QVTKOpenGLWidget (instead of QVTKWidget)
set(Slicer_VTK_USE_QVTKOPENGLWIDGET 1)
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
# NOTE: For CTEST_USE_LAUNCHER to work, it's required to include CTest at the superbuild level.
# See https://www.kitware.com/blog/home/post/11
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) # Do not add CTest default targets
include(CTest)
# Add Experimental target - Adapted from CTestTargets.cmake
set(__conf_types "")
if(CMAKE_CONFIGURATION_TYPES)
# We need to pass the configuration type on the test command line.
set(__conf_types -C "$<CONFIG>")
endif()
add_custom_target(Experimental ${CMAKE_CTEST_COMMAND} ${__conf_types} -D Experimental)
if(Slicer_SUPERBUILD)
set(_slicer_dir ${CMAKE_BINARY_DIR}/${Slicer_BINARY_INNER_SUBDIR})
else()
set(_slicer_dir ${Slicer_BINARY_DIR})
endif()
set(Slicer_LAUNCHER_EXECUTABLE ${_slicer_dir}/${Slicer_MAIN_PROJECT_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX})
set(Slicer_LAUNCH_COMMAND ${Slicer_LAUNCHER_EXECUTABLE} --launch)
#-----------------------------------------------------------------------------
# ExternalData Object Stores configuration
#-----------------------------------------------------------------------------
set(ExternalData_OBJECT_STORES_DEFAULT "${Slicer_BINARY_DIR}/ExternalData/Objects")
if(DEFINED "ENV{ExternalData_OBJECT_STORES}")
set(ExternalData_OBJECT_STORES_DEFAULT $ENV{ExternalData_OBJECT_STORES})
endif()
if(NOT DEFINED ExternalData_OBJECT_STORES)
set(ExternalData_OBJECT_STORES "${ExternalData_OBJECT_STORES_DEFAULT}")
endif()
message(STATUS "Setting ExternalData_OBJECT_STORES to '${ExternalData_OBJECT_STORES}'")
set(Slicer_ExternalData_DATA_MANAGEMENT_TARGET ${PROJECT_NAME}Data)
#-----------------------------------------------------------------------------
# Get operating system, architecture and bitness
#-----------------------------------------------------------------------------
SlicerMacroGetOperatingSystemArchitectureBitness(VAR_PREFIX Slicer)
message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} for [${Slicer_OS}-${Slicer_ARCHITECTURE}]")
#-----------------------------------------------------------------------------
# Superbuild script
#-----------------------------------------------------------------------------
if(Slicer_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
return()
endif()
foreach(dep QT ${Slicer_DEPENDENCIES})
if(Slicer_USE_SYSTEM_${dep})
message(STATUS "Using system ${dep}")
endif()
endforeach()
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${vtkAddon_CMAKE_DIR}
${CMAKE_MODULE_PATH}
)
#-----------------------------------------------------------------------------
# Folders
#-----------------------------------------------------------------------------
set_property(GLOBAL PROPERTY USE_FOLDERS ${Slicer_USE_FOLDERS})
#-----------------------------------------------------------------------------
# Clear SlicerTargets.cmake
#-----------------------------------------------------------------------------
file(WRITE "${Slicer_BINARY_DIR}/SlicerTargets.cmake" "")
#-----------------------------------------------------------------------------
# Output directories.
#------------------------------------------------------------------------------
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_BIN_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_BIN_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_LIB_DIR})
#-----------------------------------------------------------------------------
# Slicer Home
#------------------------------------------------------------------------------
set(Slicer_HOME "${Slicer_BINARY_DIR}")
#-----------------------------------------------------------------------------
# Slicer include and libraries subdirectory
#-----------------------------------------------------------------------------
set(Slicer_Base_LIBRARIES CACHE INTERNAL "Slicer Base libraries" FORCE)
set(Slicer_Base_INCLUDE_DIRS CACHE INTERNAL "Slicer Base includes" FORCE)
set(Slicer_ModuleLogic_INCLUDE_DIRS CACHE INTERNAL "Slicer Module logic includes" FORCE)
set(Slicer_ModuleMRML_INCLUDE_DIRS CACHE INTERNAL "Slicer Module MRML includes" FORCE)
set(Slicer_ModuleWidgets_INCLUDE_DIRS CACHE INTERNAL "Slicer Module Widgets includes" FORCE)
#-----------------------------------------------------------------------------
# ExternalData configuration for test data
#-----------------------------------------------------------------------------
list(APPEND ExternalData_URL_TEMPLATES "https://github.com/Slicer/SlicerTestingData/releases/download/%(algo)/%(hash)")
include(ExternalData)
set(Slicer_ExternalData_OBJECT_STORES ${ExternalData_OBJECT_STORES})
set(Slicer_ExternalData_URL_TEMPLATES ${ExternalData_URL_TEMPLATES})
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
include(SlicerMacroConfigureModuleCxxTestDriver)
include(SlicerMacroSimpleTest)
include(SlicerMacroPythonTesting)
include(SlicerMacroConfigureGenericCxxModuleTests)
include(SlicerMacroConfigureGenericPythonModuleTests)
if(BUILD_TESTING)
# The variable CXX_TEST_PATH should *NOT* be used when adding tests.
# Instead the the $<TARGET_FILE:...> generator expression should be
# considered. See r16586 for more details.
set(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # XXX
configure_file(
${Slicer_SOURCE_DIR}/CTestConfig.cmake
${Slicer_BINARY_DIR}/${Slicer_BIN_DIR}/CTestConfig.cmake
COPYONLY)
add_subdirectory(CMake/Testing)
add_subdirectory(Extensions/CMake/Testing)
if(Slicer_BUILD_CLI_SUPPORT)
set(SEM_LAUNCH_COMMAND ${Slicer_LAUNCH_COMMAND})
set(SEM_DATA_MANAGEMENT_TARGET ${Slicer_ExternalData_DATA_MANAGEMENT_TARGET})
endif()
endif()
#-----------------------------------------------------------------------------
# NOTE: How to include dependent packages ?
#-----------------------------------------------------------------------------
# Every Slicer sub project, library or module is responsible
# to call find_package (optionally specifying a list of components)
# and (if it applies) include the associated "use file".
#
# This means that moving forward most of the find_package calls listed below
# will be removed.
#-----------------------------------------------------------------------------
# VTK
#-----------------------------------------------------------------------------
find_package(VTK REQUIRED)
set(VTK_LIBRARIES "")
find_package(VTK ${Slicer_VTK_VERSION_MAJOR} COMPONENTS ${Slicer_VTK_COMPONENTS} REQUIRED)
set(VTK_GUI_SUPPORT_QT_TARGET_NAME "VTK::GUISupportQt")
if(NOT TARGET ${VTK_GUI_SUPPORT_QT_TARGET_NAME})
message(FATAL_ERROR "error: VTK was not configured to use Qt, you probably need "
"to recompile it with VTK_USE_GUISUPPORT ON, VTK_Group_Qt ON, "
"Note that Qt >= ${Slicer_REQUIRED_QT_VERSION} is *required*")
endif()
set(VTK_RENDERING_BACKEND "${Slicer_VTK_RENDERING_BACKEND}")
#-----------------------------------------------------------------------------
# CTK
#-----------------------------------------------------------------------------
find_package(CTK REQUIRED)
include(${CTK_USE_FILE})
#-----------------------------------------------------------------------------
# Update CMake module path
#-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${CTK_CMAKE_DIR}
${CMAKE_MODULE_PATH}
${CTK_CMAKE_UTILITIES_DIR})
#-----------------------------------------------------------------------------
# CMake Function(s) and Macro(s) from CTK
#-----------------------------------------------------------------------------
include(ctkFunctionAddExecutableUtf8)
#-----------------------------------------------------------------------------
# Set Slicer_PYTHON_VERSION and Slicer_PYTHON_VERSION_DOT
#-----------------------------------------------------------------------------
if(Slicer_USE_PYTHONQT)
find_package(PythonLibs ${Slicer_REQUIRED_PYTHON_VERSION_DOT} REQUIRED)
find_package(PythonInterp ${Slicer_REQUIRED_PYTHON_VERSION_DOT} REQUIRED)
# Extract python lib path
get_filename_component(PYTHON_DIR_PATH ${PYTHON_EXECUTABLE} PATH)
set(PYTHON_LIBRARY_PATH ${PYTHON_DIR_PATH}/../lib)
if(WIN32)
set(PYTHON_LIBRARY_PATH ${PYTHON_DIR_PATH})
endif()
# Extract python version components
ctkMacroSetPaths("${PYTHON_LIBRARY_PATH}")
function(_python_sys_attribute attribute varname)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(sys.${attribute})"
OUTPUT_VARIABLE value
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${varname} ${value} PARENT_SCOPE)
endfunction()
_python_sys_attribute("version_info.major" Slicer_PYTHON_VERSION_MAJOR)
_python_sys_attribute("version_info.minor" Slicer_PYTHON_VERSION_MINOR)
_python_sys_attribute("version_info.micro" Slicer_PYTHON_VERSION_PATCH)
_python_sys_attribute("abiflags" Slicer_PYTHON_ABIFLAGS)
set(Slicer_PYTHON_VERSION_DOT "${Slicer_PYTHON_VERSION_MAJOR}.${Slicer_PYTHON_VERSION_MINOR}")
set(Slicer_PYTHON_VERSION "${Slicer_PYTHON_VERSION_MAJOR}${Slicer_PYTHON_VERSION_MINOR}")
message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} with python ${Slicer_PYTHON_VERSION_DOT}${Slicer_PYTHON_ABIFLAGS}")
set(CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME "Slicer")
endif()
#-----------------------------------------------------------------------------
# PythonQt
#-----------------------------------------------------------------------------
if(Slicer_USE_PYTHONQT)
# Find PythonQt package so that PYTHONQT_USE_RELEASE_PYTHON_FALLBACK is defined
# See https://github.com/commontk/PythonQt/issues/7
# and https://github.com/commontk/PythonQt/issues/8
find_package(PythonQt REQUIRED)
link_directories(${PYTHONQT_INSTALL_DIR}/lib)
include(ctkMacroWrapPythonQt)
include(ctkMacroCompilePythonScript)
# Enable qMRMLWidgets python wrapping
set(MRMLWidgets_WRAP_PYTHON ON)
# See vtkAddon/CMake/vtkMacroKitPythonWrap.cmake
set(Slicer_VTK_WRAP_HIERARCHY_DIR ${Slicer_BINARY_DIR})
endif()
#-----------------------------------------------------------------------------
# Teem
#-----------------------------------------------------------------------------
# XXX Waiting teem provide a correct TeemConfig.cmake exporting targets, this is needed
# to ensure the link_directories for teem is defined and avoid error like:
# warning: libteem.so.1, needed by ../../../../bin/libvtkTeem.so, may conflict with libteem.so.2
find_package(Teem REQUIRED)
include(${Teem_USE_FILE})
#-----------------------------------------------------------------------------
# SlicerExecutionModel settings
#-----------------------------------------------------------------------------
set(SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES "" CACHE INTERNAL "SlicerExecutionModel extra includes" FORCE)
set(SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES "" CACHE INTERNAL "SlicerExecutionModel extra executable target libraries" FORCE)
#-----------------------------------------------------------------------------
# Set Slicer builtin libraries *_DIR variables
#-----------------------------------------------------------------------------
set(GenerateLM_DIR ${Slicer_BINARY_DIR}/Libs/GenerateLM)
set(vtkITK_DIR ${Slicer_BINARY_DIR}/Libs/vtkITK)
#-----------------------------------------------------------------------------
# Set COVERAGE_{C,CXX}_FLAGS variables
#-----------------------------------------------------------------------------
include(SlicerBlockCXXCoverageFlags)
#-----------------------------------------------------------------------------
# Set ITK_REQUIRED_{C,CXX}_FLAGS variables
#-----------------------------------------------------------------------------
include(ITKPlatformSpecificChecks)