CMakeLists.txt 9.19 KB
Newer Older
1
cmake_minimum_required(VERSION 3.12)
2
3

project(LidarViewSuperBuild)
4
5
6
7
8
set (SuperBuild_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
set (SuperBuild_PROJECTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Projects")
set (SuperBuild_BINARY_DIR ${LidarViewSuperBuild_BINARY_DIR}) # required to do FindPackage(ParaView) inside LidarView's CMakeLists

set(qt_version 5)
9
list(APPEND qt5_extra_options -no-icu)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

macro (superbuild_setup_variables)
  include(SuperbuildVersionMacros)
  # if (paraview_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(PARAVIEW_VERSION_DEFAULT "5.5.0"
  #     CACHE STRING "The default version of ParaView to use if it cannot be detected")
  #   mark_as_advanced(PARAVIEW_VERSION_DEFAULT)
  #   set(paraview_default_version "${PARAVIEW_VERSION_DEFAULT}")
  # elseif (paraview_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(paraview_default_version "")
  # else ()
  #   # The selection is the version number; use it.
  #   set(paraview_default_version "${paraview_SOURCE_SELECTION}")
  # endif()
  # superbuild_set_version_variables(paraview "${paraview_default_version}" "paraview-version.cmake" "version.txt")
  # set(paraview_version "${paraview_version_major}.${paraview_version_minor}")
30
  set(paraview_version "5.6")
31
32
33
34
35
36
37
38
39
40
41
endmacro ()
#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

42
#-----------------------------------------------------------------------------
43
44
45
46
# Collect information about the build platform.
include(CheckTypeSize)
check_type_size(void* VOID_PTR_SIZE BUILTIN_TYPES_ONLY)
if (VOID_PTR_SIZE EQUAL 8)
47
  set(LV_BUILD_ARCHITECTURE "64")
48
else ()
49
  set(LV_BUILD_ARCHITECTURE "32")
50
51
52
53
endif()

# Set suffix to be used for generating archives. This ensures that the package
# files have decent names that we can directly upload to the website.
54
set (package_suffix "${CMAKE_SYSTEM_NAME}-${LV_BUILD_ARCHITECTURE}bit")
55

56
#-----------------------------------------------------------------------------
57
58
59
# Setup CMAKE_MODULE_PATH so that platform specific configurations are processed
# before the generic ones.
set (CMAKE_MODULE_PATH
60
61
62
63
  "${SuperBuild_PROJECTS_DIR}"
  "${SuperBuild_CMAKE_DIR}"
  "${CMAKE_CURRENT_SOURCE_DIR}"
  "${CMAKE_CURRENT_SOURCE_DIR}/../CMake"
64
65
  ${CMAKE_MODULE_PATH})

66
67
68
function (superbuild_find_projects var)
  # Some of these allow using system libraries.
  set(projects
69
70
71
    cxx11
    paraview
    python
72
    python3
73
74
    qt5
    pythonqt
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    boost
    bzip2
    eigen
    liblas
    freetype
    opencv
    pcap
    png
    zlib
    ceres
    glog
    pcl
    qhull
    flann
    nanoflann
    yaml
    darknet
Nicolas Cadart's avatar
Nicolas Cadart committed
92
    g2o
93
94
95
96
97
    )

  if (UNIX)
    list(APPEND projects
      libxml2
98
      ffi
99
100
101
102
103
104
    )

    if (NOT APPLE)
      list(APPEND projects
        fontconfig
        gperf
105
        utillinux
106
107
108
109
      )
    endif()
  endif()

110
  if (COMMAND add_project_to_superbuild)
111
    add_project_to_superbuild(projects)
112
  else (COMMAND add_project_to_superbuild)
113
	  message(WARNING "The function add_project_to_superbuild is not defined. Only LidarView's common dependencies will be compile.")
114
  endif(COMMAND add_project_to_superbuild)
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
  set("${var}"
    ${projects}
    PARENT_SCOPE)
endfunction ()


if (WIN32)
  if ( (NOT "${CMAKE_GENERATOR}" MATCHES "^NMake.*$") OR
       (NOT "${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*$"))
    # not use VS environment. We need to be pointed to nmake and devenv paths
    # since they are needed when building tools (qt, python, etc.)
    find_program(DEVENV_PATH devenv)
    find_program(NMAKE_PATH nmake)
    mark_as_advanced(DEVENV_PATH NMAKE_PATH)
  endif()
endif()

132
133
134
# Enable python 3 for the whole superbuild
set(ENABLE_python3 True CACHE BOOL INTERNAL)

135
if(UNIX)
136
137
138
139
140
141
142
  # The following variable is used to define if python libs have to be used from the system 
  # directory (USE_SYSTEM_python3=True) or shipped in install dir (USE_SYSTEM_python3=False)
  # this behavior is managed by the superbuild python install functions
  if(NOT DEFINED USE_SYSTEM_python3)
    # it is still possible to pass -DUSE_SYSTEM_python3=False to cmake
    message(STATUS "Defaulting USE_SYSTEM_python3 to True (was undefined and we are on UNIX)")
    set(USE_SYSTEM_python3 True CACHE BOOL INTERNAL)
143
144
  endif()

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
  # This is needed to ensure the superbuild projects to use the same python version.
  # We force python to version 3.7 as it is the only one that has been tested
  find_package(Python3 3.7 EXACT QUIET REQUIRED COMPONENTS Interpreter Development)

  # By setting the following variables we specify a python version for FindPythonLibs
  # (See cmake FindPythonLibs documentation)
  set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
  set(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS})
  set(PYTHON_LIBRARY ${Python3_LIBRARIES})
  
  # Python3_INCLUDE_DIR and Python3_LIBRARY are Artefacts in FindPython3
  # Both can be used to specific a python version
  # (See cmake FindPython3 documentations)
  set(Python3_INCLUDE_DIR ${Python3_INCLUDE_DIRS})
  set(Python3_LIBRARY ${Python3_LIBRARIES})
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
endif()

function (superbuild_add_packaging)
  if (WIN32)
    set(generators
      ZIP
      NSIS)
  elseif (APPLE)
    set(generators
      DragNDrop)
  else ()
    set(generators
      TGZ
      TXZ)
  endif ()
  list(GET generators 0 default_generator)

177
  if (qt5_enabled AND (USE_SYSTEM_qt5 OR APPLE OR WIN32))
178
179
    list(APPEND superbuild_export_variables
      Qt5_DIR)
180
181
182
183
    find_package(Qt5 QUIET REQUIRED COMPONENTS Core)
    set(qt5_version "${Qt5Core_VERSION_MAJOR}.${Qt5Core_VERSION_MINOR}")
  else ()
    set(qt5_version "${qt5_SOURCE_SELECTION}")
184
  endif ()
185
186
187
  list(APPEND superbuild_export_variables
    qt5_version)
  
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

  # pass some variables that are required for packaging step:
  list(APPEND superbuild_export_variables
    PARAVIEW_VERSION
    package_suffix
    )

  set(default_package lidarview)
  foreach (generator IN LISTS generators)
      superbuild_add_extra_package_test(lidarview "${generator}"
      LABELS  "LidarView" # does not have to be ${SOFTWARE_NAME} I think
      TIMEOUT 6400)
  endforeach ()

  if (default_package)
    superbuild_enable_install_target("${default_package}/${default_generator}")
  endif ()
205
206
endfunction ()

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
function (superbuild_add_tests)
  # TODO: add existing tests
  # add_subdirectory("${CMAKE_SOURCE_DIR}/tests" "${CMAKE_BINARY_DIR}/tests")
endfunction ()

# skiped module as defined in paraview superbuild.
# One difference: pythonQt needs Multimedia so we don't skip it.
set(qt5_skip_modules
  qtspeech
  qtconnectivity
  qtgamepad
  qtlocation
  qtsensors
  qtserialport
  qtwayland
  qtwebchannel
  qtwebengine
  qtwebsockets)
list(APPEND qt5_process_environment
  BUILD_IN_SOURCE 1)

set(boost_libraries
  date_time
  filesystem
  iostreams
  program_options
233
  thread
234
235
  chrono
  regex
236
  system)
237
238
239
set(boost_extra_options
  "-sNO_BZIP2=1")

240
241
list(APPEND superbuild_version_files
  "${CMAKE_CURRENT_LIST_DIR}/versions.cmake")
242
243
244
245
246
list(APPEND superbuild_project_roots
  "${SuperBuild_PROJECTS_DIR}")

set(_superbuild_default_cxx11 ON)

247
248
249
# set the default for qt5 to be 5.10
set(_superbuild_qt5_default_selection "5.10")

250
251
252
253
254
255
256
option(ENABLE_all "Enable all optional dependancy like pcl, ceres, opencv, darknet, ..." OFF)
if (ENABLE_all)
  set(ENABLE_opencv ON CACHE BOOL "enable OpenCV")
  set(ENABLE_ceres ON CACHE BOOL "enable Ceres")
  set(ENABLE_pcl ON CACHE BOOL "enable PCL")
  set(ENABLE_nanoflann ON CACHE BOOL "enable nanoflann")
  set(ENABLE_darknet ON CACHE BOOL "enable darknet")
Nicolas Cadart's avatar
Nicolas Cadart committed
257
  set(ENABLE_g2o ON CACHE BOOL "enable G2O")
258
endif(ENABLE_all)
259

260
261
262
263
264
265
266
267
option(ENABLE_slam "Build Lidar SLAM (requires PCL, Ceres, nanoflann; optional g2o)" OFF)
option(ENABLE_old_slam "Build old deprecated Lidar SLAM (requires PCL, Ceres, nanoflann). Should not be used if new SLAM is being built." OFF)
mark_as_advanced(ENABLE_old_slam)
if (ENABLE_slam AND ENABLE_old_slam)
  message(WARNING "ENABLE_slam and ENABLE_old_slam are both set to ON. "
                  "It is strongly recommended to build only one of these two SLAM filters to avoid runtime errors due to names collisions.")
endif(ENABLE_slam AND ENABLE_old_slam)

268
add_subdirectory(common-superbuild)
269
270
271
272
273
274
275

# Check if some Boost environment variables could hide local Boost install
if (NOT ${USE_SYSTEM_boost} AND (DEFINED ENV{BOOSTROOT} OR DEFINED ENV{BOOST_ROOT} OR DEFINED ENV{BOOST_LIBRARYDIR} OR DEFINED ENV{BOOST_INCLUDEDIR}))
  message(WARNING "Some Boost environment variables are set and may hide the local superbuild Boost installation. "
                  "Consider enabling USE_SYSTEM_boost flag or unsetting the following environement variables :\n"
                  " BOOSTROOT=$ENV{BOOSTROOT}\n BOOST_ROOT=$ENV{BOOST_ROOT}\n BOOST_LIBRARYDIR=$ENV{BOOST_LIBRARYDIR}\n BOOST_INCLUDEDIR=$ENV{BOOST_INCLUDEDIR}")
endif()