CMakeLists.txt 9.61 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
170
  if (NOT DEVELOPER_MODE_smtk)
    list(APPEND projects
      smtkresourcemanagerstate)
171
  endif ()
T.J. Corona's avatar
T.J. Corona committed
172

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

176
177
178
179
  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
180
181
      capstone
      cubit
182
183
      triangle)
  endif ()
184

185
186
187
188
189
190
191
192
193
194
  # 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 ()

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

200
function (superbuild_sanity_check)
201
  if (vtkonly_enabled AND paraview_enabled)
T.J. Corona's avatar
T.J. Corona committed
202
    message(FATAL_ERROR
203
      "Only one of the following projects should be enabled: vtkonly, paraview.")
T.J. Corona's avatar
T.J. Corona committed
204
  endif ()
205
  if (NOT smtk_enabled AND NOT cmb_enabled)
206
    message(FATAL_ERROR
207
      "At least one of the following projects must be enabled: cmb, or smtk.")
208
  endif ()
209
210
211
212
213
214
215
216
217
218
219
220
221
222
  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()
223
224
endfunction ()

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

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

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

244
245
246
  # 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
247
  if (UNIX AND NOT APPLE AND NOT USE_SYSTEM_qt5)
Ben Boeckel's avatar
Ben Boeckel committed
248
    set(Qt5_DIR "${superbuild_install_location}/lib/cmake/Qt5")
Ben Boeckel's avatar
Ben Boeckel committed
249
250
    set(qt5_version "${qt5_SOURCE_SELECTION}")
  else ()
Ben Boeckel's avatar
Ben Boeckel committed
251
252
    list(APPEND superbuild_export_variables
      Qt5_DIR)
253
254
    find_package(Qt5 QUIET REQUIRED COMPONENTS Core)
    set(qt5_version "${Qt5Core_VERSION_MAJOR}.${Qt5Core_VERSION_MINOR}")
Ben Boeckel's avatar
Ben Boeckel committed
255
  endif ()
256
257
  list(APPEND superbuild_export_variables
    qt5_version)
Ben Boeckel's avatar
Ben Boeckel committed
258

259
260
261
  list(APPEND superbuild_export_variables
    BOOST_ADDITIONAL_LIBRARIES)

262
  include(package.test)
263

264
265
266
267
268
269
  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
270

271
272
273
274
275
276
277
278
279
280
  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)
281

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

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

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

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

311
312
313
314
315
316
317
318
319
320
# 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
321
# Default Qt5 to ON
Ben Boeckel's avatar
Ben Boeckel committed
322
set(_superbuild_default_qt5 ON)
Ben Boeckel's avatar
Ben Boeckel committed
323

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

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

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

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

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

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

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

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

392
393
set(_superbuild_package_default "modelbuilder")

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

403
add_subdirectory(superbuild)
404
405
406
407

if (BUILD_TESTING)
  include(CTest)
endif ()