CMakeLists.txt 9.63 KB
Newer Older
1
cmake_minimum_required(VERSION 3.11.2)
2

3
4
project(cmb-superbuild)

5
6
7
8
9
10
11
12
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND
    NOT CMAKE_HOST_SYSTEM_VERSION VERSION_LESS "20.2.0" # macOS 11
    AND CMAKE_VERSION VERSION_LESS "3.19.0")
  message(AUTHOR_WARNING
    "Note that macOS 11 has changes which requires CMake 3.19.0 to "
    "successfully package the applications.")
endif ()

13
14
15
list(INSERT CMAKE_MODULE_PATH 0
  "${CMAKE_CURRENT_LIST_DIR}/cmake")

16
17
18
19
20
21
22
23
24
macro(set_cmb_python_modules)
  set(cmb_python_modules
    smtk
    paraview
    cinema_python
    pygments
    six
    vtk
    vtkmodules)
25

26
27
28
  if (matplotlib_enabled)
    list(APPEND cmb_python_modules
      matplotlib)
29
30
  endif ()

31
32
33
34
35
36
37
38
39
40
41
42
  if (numpy_enabled)
    list(APPEND cmb_python_modules
      numpy)
  endif ()

  if (pythongirderclient_enabled)
    list(APPEND cmb_python_modules
      diskcache
      requests
      requests_toolbelt
      girder_client)
  endif ()
T.J. Corona's avatar
T.J. Corona committed
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  if (paraviewweb_enabled)
    list(APPEND cmb_python_modules
      autobahn
      constantly
      incremental
      twisted
      wslink
      zope)

    if (WIN32)
      list(APPEND cmb_python_modules
        adodbapi
        isapi
        pythoncom
        win32com)
59
    endif ()
60
61
62
63
64
65
66
  endif ()

  get_property(has_extra_python_modules GLOBAL PROPERTY cmb_extra_python_modules SET)
  if(has_extra_python_modules)
    get_property(extra_python_modules GLOBAL PROPERTY cmb_extra_python_modules)
    list(APPEND cmb_python_modules
      ${extra_python_modules})
67
  endif()
68
69
70
71
72
73
74
75
76
77
78
endmacro()

macro (superbuild_setup_variables)
  include(SuperbuildVersionMacros)

  superbuild_configure_project_version(cmb)
  superbuild_configure_project_version(smtk)
  superbuild_configure_project_version(paraview "for-v6.3.0" "master")

  superbuild_set_version_variables(vtk "9.0.0" "vtk-version.cmake")
  set(vtk_version "${vtk_version_major}.${vtk_version_minor}")
79
80
81
endmacro ()

function (superbuild_find_projects var)
82
83
  include(CMBSuperbuildMacros)

84
85
86
87
  set(projects
    boost
    bzip2
    cmb
88
    cmbusersguide
89
    cmbworkflows
90
    cumulus
Ben Boeckel's avatar
Ben Boeckel committed
91
    cxx11
92
    eigen
93
    fortran
94
    freetype
Ben Boeckel's avatar
Ben Boeckel committed
95
    ftgl
96
97
    gdal
    hdf5
98
99
    itk
    itkvtkglue
100
    lapack
Ben Boeckel's avatar
Ben Boeckel committed
101
    las
102
    libarchive
T.J. Corona's avatar
T.J. Corona committed
103
    matplotlib
104
105
    moab
    netcdf
106
    netgen
107
    nlohmannjson
Jacob Becker's avatar
Jacob Becker committed
108
    numpy
David Thompson's avatar
David Thompson committed
109
    occt
110
    opencascadesession
Jacob Becker's avatar
Jacob Becker committed
111
    opencv
112
    paraview
113
114
115
    paraviewweb
    paraviewwebvisualizer
    paraviewweblightviz
David Thompson's avatar
David Thompson committed
116
    pegtl
117
    png
T.J. Corona's avatar
T.J. Corona committed
118
    protobuf
T.J. Corona's avatar
T.J. Corona committed
119
    pyarc
120
    pybind11
121
    python
122
    python2
123
    python3
T.J. Corona's avatar
T.J. Corona committed
124
    pythoncycler
125
    pythoncython
T.J. Corona's avatar
T.J. Corona committed
126
    pythondateutil
127
    pythondiskcache
128
    pythongirderclient
T.J. Corona's avatar
T.J. Corona committed
129
    pythonkiwisolver
Ben Boeckel's avatar
Ben Boeckel committed
130
    pythonmeshio
T.J. Corona's avatar
T.J. Corona committed
131
    pythonpyparsing
132
    pythonrequests
133
    pythonrequeststoolbelt
134
    pythonsetuptools
T.J. Corona's avatar
T.J. Corona committed
135
    pythonsix
Ben Boeckel's avatar
Ben Boeckel committed
136
    pythonwheel
T.J. Corona's avatar
T.J. Corona committed
137
    pytz
138
    qt5
139
    remus
T.J. Corona's avatar
T.J. Corona committed
140
    rggsession
141
    smtk
142
    smtkusersguide
143
    szip
T.J. Corona's avatar
T.J. Corona committed
144
    vtk
145
    vtkonly
146
147
148
149
    vxl
    zeromq
    zlib)

150
151
  if (NOT WIN32)
    list(APPEND projects
152
      ffi
153
      fontconfig
154
      gperf
155
      libxml2
156
      meshkit
157
      pkgconf
158
      sqlite
159
      utillinux)
160
161
  endif ()

162
163
  if (WIN32)
    list(APPEND projects
Ben Boeckel's avatar
Ben Boeckel committed
164
      ftjam
165
      pywin32)
166
167
  endif ()

168
169
  if (NOT DEVELOPER_MODE_smtk)
    list(APPEND projects
John Tourtellott's avatar
John Tourtellott committed
170
      smtkprojectmanager
171
      smtkresourcemanagerstate)
172
  endif ()
T.J. Corona's avatar
T.J. Corona committed
173

174
  # For now it's a convenient option to control smtk documentation.
175
  option(ENABLE_DOCUMENTATION "Enable smtk documentation" ON)
176

177
178
179
180
  option(USE_NONFREE_COMPONENTS "Enable the non-free parts of the superbuild" OFF)
  mark_as_advanced(USE_NONFREE_COMPONENTS)
  if (USE_NONFREE_COMPONENTS)
    list(APPEND projects
181
182
      capstone
      cubit
183
184
      triangle)
  endif ()
185

186
187
188
189
190
191
192
193
194
195
  # Capstone and Cubit are closed-source programs to which Kitware developers
  # have access. We provide logic for situating these programs into our
  # superbuild for development purposes only. These packages are not bundled or
  # distributed.
  set(KW_SHARE "" CACHE PATH "Location of Kitware-internal share directory.")

  if (NOT (capstone_enabled OR cubit_enabled))
    mark_as_advanced(KW_SHARE)
  endif ()

196
197
198
199
  set("${var}"
    ${projects}
    PARENT_SCOPE)
endfunction ()
200

201
function (superbuild_sanity_check)
202
  if (vtkonly_enabled AND paraview_enabled)
T.J. Corona's avatar
T.J. Corona committed
203
    message(FATAL_ERROR
204
      "Only one of the following projects should be enabled: vtkonly, paraview.")
T.J. Corona's avatar
T.J. Corona committed
205
  endif ()
206
  if (NOT smtk_enabled AND NOT cmb_enabled)
207
    message(FATAL_ERROR
208
      "At least one of the following projects must be enabled: cmb, or smtk.")
209
  endif ()
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  if (NOT SUPERBUILD_PACKAGE_MODE STREQUAL "<none>")
    get_property(not_sane GLOBAL PROPERTY ${SUPERBUILD_PACKAGE_MODE}_REQUIRED_PROJECTS SET)
    get_property(package_required_projects GLOBAL PROPERTY ${SUPERBUILD_PACKAGE_MODE}_REQUIRED_PROJECTS)
    foreach (project IN LISTS package_required_projects)
      if (${project}_enabled)
        set(not_sane FALSE)
      endif ()
    endforeach ()
    if (not_sane)
      string(REPLACE ";" ", " required_projects "${package_required_projects}")
      message(FATAL_ERROR
        "At least one of the following projects must be enabled: ${require_projects}.")
    endif ()
  endif()
224
225
endfunction ()

226
function (superbuild_add_packaging)
227
  if (SUPERBUILD_PACKAGE_MODE STREQUAL "<none>" OR DEVELOPER_MODE_cmb)
228
229
230
    return ()
  endif ()

231
232
233
234
235
236
237
238
239
240
241
  if (WIN32)
    set(generators
      ZIP)
  elseif (APPLE)
    set(generators
      DragNDrop)
  else ()
    set(generators
      TGZ)
  endif ()

242
243
244
  set_cmb_python_modules()
  list(APPEND superbuild_export_variables cmb_python_modules)

245
246
247
  # Force qt SVG support, so CMB/ParaView can use SVG icons
  set(qt5_ENABLE_SVG ON CACHE INTERNAL "CMB/ParaView requires SVG support")

Ben Boeckel's avatar
Ben Boeckel committed
248
  if (UNIX AND NOT APPLE AND NOT USE_SYSTEM_qt5)
Ben Boeckel's avatar
Ben Boeckel committed
249
    set(Qt5_DIR "${superbuild_install_location}/lib/cmake/Qt5")
Ben Boeckel's avatar
Ben Boeckel committed
250
251
    set(qt5_version "${qt5_SOURCE_SELECTION}")
  else ()
Ben Boeckel's avatar
Ben Boeckel committed
252
253
    list(APPEND superbuild_export_variables
      Qt5_DIR)
254
255
    find_package(Qt5 QUIET REQUIRED COMPONENTS Core)
    set(qt5_version "${Qt5Core_VERSION_MAJOR}.${Qt5Core_VERSION_MINOR}")
Ben Boeckel's avatar
Ben Boeckel committed
256
  endif ()
257
258
  list(APPEND superbuild_export_variables
    qt5_version)
Ben Boeckel's avatar
Ben Boeckel committed
259

260
261
262
  list(APPEND superbuild_export_variables
    BOOST_ADDITIONAL_LIBRARIES)

263
  include(package.test)
264

265
266
267
268
269
270
  get_property(PACKAGE_LABELS GLOBAL PROPERTY "${SUPERBUILD_PACKAGE_MODE}_PACKAGE_LABELS")
  get_property(PACKAGE_SUFFIX GLOBAL PROPERTY "${SUPERBUILD_PACKAGE_MODE}_PACKAGE_SUFFIX")
  superbuild_package_suffix(PACKAGE_SUFFIX)

  list(APPEND superbuild_export_variables
    PACKAGE_SUFFIX)
T.J. Corona's avatar
T.J. Corona committed
271

272
273
274
275
276
277
278
279
280
281
  set("${SUPERBUILD_PACKAGE_MODE}_PACKAGE_FILE_NAME" ""
    CACHE STRING "If set, overrides the generated filename for the package")
  set(PACKAGE_FILE_NAME ${SUPERBUILD_PACKAGE_MODE}_PACKAGE_FILE_NAME)
  list(APPEND superbuild_export_variables
    PACKAGE_FILE_NAME)

  foreach (generator IN LISTS generators)
    superbuild_add_extra_package_test(${SUPERBUILD_PACKAGE_MODE} "${generator}"
      LABELS  "${PACKAGE_LABELS}"
      TIMEOUT 6400)
282

283
284
    # TODO: Enable these tests in general
    if (SUPERBUILD_PACKAGE_MODE STREQUAL "modelbuilder")
285
      add_package_extract_test("${generator}"
286
287
        DEPENDS "cpack-${SUPERBUILD_PACKAGE_MODE}-${generator}"
        LABELS  "${PACKAGE_LABELS}"
288
289
290
        )

      add_package_import_test("${generator}"
291
292
        DEPENDS "extract-${SUPERBUILD_PACKAGE_MODE}-${generator}"
        LABELS  "${PACKAGE_LABELS}"
293
        )
294
295
    endif ()
  endforeach ()
296
endfunction ()
297

298
299
macro (superbuild_setup_tests)
  if (cmb_enabled)
300
    set(DROP_LOCATION "/submit.php?project=CMB")
301
  elseif (smtk_enabled)
302
    set(DROP_LOCATION "/submit.php?project=SMTK")
303
304
305
  endif ()
endmacro ()

306
307
308
309
310
function (superbuild_add_tests)
  set_property(GLOBAL APPEND
    PROPERTY
      superbuild_test_projects cmb smtk)
endfunction ()
311

312
313
314
315
316
317
318
319
320
321
# Make binaries on linux more compatible by default
option(SB_LINUX_CORE2_COMPATIBLE "On linux, enable core2 architecture compatible builds, disabling avx512f" ON)
mark_as_advanced(SB_LINUX_CORE2_COMPATIBLE)
if (SB_LINUX_CORE2_COMPATIBLE AND UNIX AND NOT APPLE AND
  (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
   CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
  string(APPEND CMAKE_C_FLAGS " -march=core2 -mno-avx512f")
  string(APPEND CMAKE_CXX_FLAGS " -march=core2 -mno-avx512f")
endif()

T.J. Corona's avatar
T.J. Corona committed
322
# Default Qt5 to ON
Ben Boeckel's avatar
Ben Boeckel committed
323
set(_superbuild_default_qt5 ON)
Ben Boeckel's avatar
Ben Boeckel committed
324

325
326
327
328
329
330
331
332
333
334
335
336
set(qt5_skip_modules
  qtconnectivity
  qtgamepad
  qtlocation
  qtmultimedia
  qtsensors
  qtserialport
  qtwayland
  qtwebchannel
  qtwebengine
  qtwebsockets)

337
set(BOOST_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional boost libraries to build and package")
338
339
mark_as_advanced(BOOST_ADDITIONAL_LIBRARIES)

340
set(boost_minimum_version 1.64.0)
341
342
343
344
345
set(boost_libraries
  atomic
  chrono
  date_time
  filesystem
346
  iostreams
David Thompson's avatar
David Thompson committed
347
  log
348
  program_options
349
  regex
350
  serialization
351
  system
David Thompson's avatar
David Thompson committed
352
  thread
353
354
  timer
  ${BOOST_ADDITIONAL_LIBRARIES})
355

356
357
358
359
360
configure_file(
  "${CMAKE_CURRENT_LIST_DIR}/cmake/CTestCustom.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom-cmb.cmake"
  @ONLY)

361
362
363
364
if (__BUILDBOT_INSTALL_LOCATION)
  set(superbuild_install_location "${__BUILDBOT_INSTALL_LOCATION}")
endif ()

365
366
367
368
369
370
371
372
set(suppress_projects
  boost
  freetype
  ftgl
  gdal
  hdf5
  netcdf
  numpy
David Thompson's avatar
David Thompson committed
373
  occt
374
  png
375
  pybind11
376
377
378
379
  szip
  vxl
  zeromq
  zlib)
380
381
382
383
384
385
386
387
388

# Default SMTK plugin omissions
list(APPEND smtk_plugin_omit
  smtkDelaunayPlugin
  smtkMeshSessionPlugin
  smtkOscillatorSessionPlugin
  smtkPolygonSessionPlugin)
set_property(GLOBAL PROPERTY smtk_plugin_omit ${smtk_plugin_omit})

389
390
391
392
foreach (suppress_project IN LISTS suppress_projects)
  set("_superbuild_suppress_${suppress_project}_output" ON)
endforeach ()

393
394
set(_superbuild_package_default "modelbuilder")

395
396
list(APPEND superbuild_version_files
  "${CMAKE_CURRENT_LIST_DIR}/versions.cmake")
397
list(APPEND superbuild_ctest_custom_files
398
399
400
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom-cmb.cmake")
list(APPEND superbuild_project_roots
  "${CMAKE_CURRENT_LIST_DIR}/projects")
401
402
403
list(APPEND superbuild_package_roots
  "${CMAKE_CURRENT_LIST_DIR}/packages")

404
add_subdirectory(superbuild)
405
406
407
408

if (BUILD_TESTING)
  include(CTest)
endif ()