CMakeLists.txt 6.44 KB
Newer Older
Ben Boeckel's avatar
Ben Boeckel committed
1
cmake_minimum_required(VERSION 3.6)
2

3 4
project(cmb-superbuild)

5 6 7
list(INSERT CMAKE_MODULE_PATH 0
  "${CMAKE_CURRENT_LIST_DIR}/cmake")

8 9
macro (superbuild_setup_variables)
  include(SuperbuildVersionMacros)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
  if (smtk_SOURCE_SELECTION STREQUAL "git")
    # Assuming master; just use the latest version, but let the user set their
    # own version in case it is actually a branch from some other version.
    set(CMB_VERSION_DEFAULT "5.0.0-develop"
      CACHE STRING "The default version of CMB to use if it cannot be detected")
    mark_as_advanced(CMB_VERSION_DEFAULT)
    set(cmb_default_version "${CMB_VERSION_DEFAULT}")
  elseif (cmb_SOURCE_SELECTION STREQUAL "source")
    # If it is a git repo, we'll get it that way, otherwise we will look at the
    # `version.txt` in the checkout.
    set(cmb_default_version "")
  else ()
    # The selection is the version number; use it.
    set(cmb_default_version "${cmb_SOURCE_SELECTION}")
  endif()
  superbuild_set_version_variables(cmb "${cmb_default_version}" "cmb-version.cmake" "version.txt")
26
  set(cmb_version "${cmb_version_major}.${cmb_version_minor}")
27
  superbuild_set_version_variables(paraview "5.4.0-RC3" "paraview-version.cmake" "version.txt")
28
  set(paraview_version "${paraview_version_major}.${paraview_version_minor}")
29 30
  superbuild_set_version_variables(vtk "8.1.0" "vtk-version.cmake")
  set(vtk_version "${vtk_version_major}.${vtk_version_minor}")
31 32 33
endmacro ()

function (superbuild_find_projects var)
34 35
  include(CMBSuperbuildMacros)

36 37 38
  set(projects
    boost
    bzip2
Ben Boeckel's avatar
Ben Boeckel committed
39
    cgm
40
    cmb
41
    cmbusersguide
42
    cmbworkflows
43
    cumulus
Ben Boeckel's avatar
Ben Boeckel committed
44
    cxx11
45
    fortran
46
    freetype
Ben Boeckel's avatar
Ben Boeckel committed
47
    ftgl
48 49
    gdal
    hdf5
50
    lapack
51 52
    moab
    netcdf
Jacob Becker's avatar
Jacob Becker committed
53
    numpy
Ben Boeckel's avatar
Ben Boeckel committed
54
    oce
55
    opencv
56
    paraview
57 58 59
    paraviewweb
    paraviewwebvisualizer
    paraviewweblightviz
60
    png
61
    pybind11
62
    python
63
    pythongirderclient
T.J. Corona's avatar
T.J. Corona committed
64
    pythonmatplotlib
65
    pythonrequests
66
    pythonsetuptools
67
    pythonsix
68
    qt
69
    qt4
70
    qt5
71 72 73
    remus
    shiboken
    smtk
74
    smtkusersguide
75
    szip
76
    vtk
77 78 79 80
    vxl
    zeromq
    zlib)

81 82 83 84 85 86
  if (NOT WIN32)
    list(APPEND projects
      fontconfig
      libxml2)
  endif ()

87 88
  if (WIN32)
    list(APPEND projects
Ben Boeckel's avatar
Ben Boeckel committed
89
      ftjam
90 91
      pythonsetuptools
      pywin32)
92 93
  endif ()

94 95 96 97 98 99
  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
      triangle)
  endif ()
100

101 102 103 104
  set("${var}"
    ${projects}
    PARENT_SCOPE)
endfunction ()
105

106
function (superbuild_sanity_check)
107 108 109 110
  if (vtk_enabled AND paraview_enabled)
    message(FATAL_ERROR
      "Only one of the following projects should be enabled: vtk, paraview.")
  endif ()
111 112 113 114
  if (NOT smtk_enabled AND NOT cmb_enabled)
    message(FATAL_ERROR
      "At least one of the following projects must be enabled: cmb, smtk.")
  endif ()
115 116 117 118 119
  if (smtk_SOURCE_SELECTION STREQUAL "from_cmb" AND NOT DEVELOPER_MODE_smtk AND
      (NOT cmb_enabled OR DEVELOPER_MODE_cmb))
    message(FATAL_ERROR
      "SMTK cannot use CMB's SMTK submodule without CMB being enabled and built by the superbuild.")
  endif ()
120 121 122 123 124 125 126 127 128 129 130 131
  if (shiboken_enabled AND pybind11_enabled)
    message(FATAL_ERROR
      "Only one python wrapping protocol should be enabled: pybind11, shiboken.")
  endif ()
  if (cmb_enabled AND NOT shiboken_enabled AND NOT pybind11_enabled)
    message(FATAL_ERROR
      "Exactly one python wrapping protocol must be enabled: pybind11, shiboken.")
  endif ()
  if (MSVC AND (MSVC_VERSION LESS 1900) AND pybind11_enabled)
    message(FATAL_ERROR
      "Visual Studio 2015 or later is required to use pybind11; use shiboken instead.")
  endif ()
132 133 134 135
  if (shiboken_enabled AND NOT ENABLE_qt4)
    message(FATAL_ERROR
      "Shiboken requires qt4; either use qt4 + shiboken or qt5 + pybind11.")
  endif ()
136 137
endfunction ()

138
function (superbuild_add_packaging)
139 140 141 142
  if (NOT cmb_enabled OR DEVELOPER_MODE_cmb)
    return ()
  endif ()

143 144 145 146 147 148 149 150 151 152 153
  if (WIN32)
    set(generators
      ZIP)
  elseif (APPLE)
    set(generators
      DragNDrop)
  else ()
    set(generators
      TGZ)
  endif ()

Ben Boeckel's avatar
Ben Boeckel committed
154 155 156 157 158
  if (USE_SYSTEM_qt4)
    list(APPEND superbuild_export_variables
      QT_LIBRARY_DIR)
  endif ()

159 160 161 162 163 164 165 166 167 168 169
  include(cmb.suffix)
  list(APPEND superbuild_export_variables
    CMB_PACKAGE_SUFFIX)

  if (cmb_enabled)
    set(CMB_PACKAGE_FILE_NAME ""
      CACHE STRING "If set, overrides the generated filename for the package")
    list(APPEND superbuild_export_variables
      CMB_PACKAGE_FILE_NAME)
  endif ()

170 171
  option(cmb_ENABLE_HYDROLOGY_PACKAGE "Build full hydrology package" ON)

172
  foreach (generator IN LISTS generators)
Ben Boeckel's avatar
Ben Boeckel committed
173 174
    superbuild_add_extra_package_test(modelbuilder "${generator}"
      LABELS  "CMB"
175
      TIMEOUT 6400)
176 177 178 179 180 181

    if (cmb_ENABLE_HYDROLOGY_PACKAGE)
      superbuild_add_extra_package_test(hydrology "${generator}"
        LABELS  "CMB"
        TIMEOUT 6400)
    endif()
182
  endforeach ()
183
endfunction ()
184

185 186
macro (superbuild_setup_tests)
  if (cmb_enabled)
187
    set(DROP_LOCATION "/submit.php?project=CMB")
188
  elseif (smtk_enabled)
189
    set(DROP_LOCATION "/submit.php?project=SMTK")
190 191 192
  endif ()
endmacro ()

193 194 195 196 197
function (superbuild_add_tests)
  set_property(GLOBAL APPEND
    PROPERTY
      superbuild_test_projects cmb smtk)
endfunction ()
198

199 200
set(CMB_TEST_DATA_ROOT "" CACHE PATH "Location of CMB's testing data")

Ben Boeckel's avatar
Ben Boeckel committed
201 202
# Default Qt5 to ON.
set(_superbuild_default_qt5 ON)
Ben Boeckel's avatar
Ben Boeckel committed
203

Ben Boeckel's avatar
Ben Boeckel committed
204
set(boost_minimum_version 1.60.0)
205 206 207 208 209
set(boost_libraries
  atomic
  chrono
  date_time
  filesystem
David Thompson's avatar
David Thompson committed
210
  log
211
  regex
212
  serialization
213
  system
David Thompson's avatar
David Thompson committed
214 215
  thread
  timer)
216

217 218 219 220 221
configure_file(
  "${CMAKE_CURRENT_LIST_DIR}/cmake/CTestCustom.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom-cmb.cmake"
  @ONLY)

222 223 224 225
if (__BUILDBOT_INSTALL_LOCATION)
  set(superbuild_install_location "${__BUILDBOT_INSTALL_LOCATION}")
endif ()

226 227 228 229 230 231 232 233 234 235 236
set(suppress_projects
  boost
  cgm
  freetype
  ftgl
  gdal
  hdf5
  netcdf
  numpy
  oce
  png
237
  pybind11
238 239 240 241 242 243 244 245 246
  shiboken
  szip
  vxl
  zeromq
  zlib)
foreach (suppress_project IN LISTS suppress_projects)
  set("_superbuild_suppress_${suppress_project}_output" ON)
endforeach ()

247 248
list(APPEND superbuild_version_files
  "${CMAKE_CURRENT_LIST_DIR}/versions.cmake")
249
list(APPEND superbuild_ctest_custom_files
250 251 252 253
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom-cmb.cmake")
list(APPEND superbuild_project_roots
  "${CMAKE_CURRENT_LIST_DIR}/projects")
add_subdirectory(superbuild)
254

255
if (TARGET "smtk" AND NOT DEVELOPER_MODE_smtk AND smtk_SOURCE_SELECTION STREQUAL "from_cmb")
256 257 258 259 260 261 262
  get_property(smtk_need_cmb_download GLOBAL
    PROPERTY smtk_need_cmb_download)
  if (smtk_need_cmb_download)
    add_dependencies("smtk"
      "cmb-download")
  endif ()
endif ()