forked from dwcaress/MB-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
376 lines (345 loc) · 12.9 KB
/
Copy pathCMakeLists.txt
File metadata and controls
376 lines (345 loc) · 12.9 KB
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
#------------------------------------------------------------------------------
# The MB-system: CMakeLists.txt 16 June 2025
#
# Copyright (c) 2023-2025 by
# David W. Caress (caress@mbari.org)
# Monterey Bay Aquarium Research Institute
# Moss Landing, California, USA
# Dale N. Chayes
# Center for Coastal and Ocean Mapping
# University of New Hampshire
# Durham, New Hampshire, USA
# Christian dos Santos Ferreira
# MARUM
# University of Bremen
# Bremen Germany
#
# MB-System was created by Caress and Chayes in 1992 at the
# Lamont-Doherty Earth Observatory
# Columbia University
# Palisades, NY 10964
#
# See README.md file for copying and redistribution conditions.
#------------------------------------------------------------------------------
#
# To build MB-System from source using CMake do (example):
#
# mkdir build
# cd build
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
#
# CMAKE_BUILD_TYPE can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
#
#------------------------------------------------------------------------------
message("----------------------------------------------------------")
message("MB-System")
message("CMake Build System")
message("David Caress (Monterey Bay Aquarium Research Institute)")
message("Johannes Schauer (University of Weurzburg)")
message("Tom O'Reilly (Monterey Bay Aquarium Research Institute)")
message("----------------------------------------------------------")
message("CMake version: ${CMAKE_VERSION}")
message("Set install directory using -DCMAKE_INSTALL_PREFIX=directory (default is /usr/local)")
message("The default build mode is release (optimized for performance, not debuggable).")
message("Enable debugging with -DCMAKE_BUILD_TYPE=Debug")
message("Build shared/static libraries with -DBUILD_SHARED_LIBS=ON/OFF")
message("Disable building graphical utilities with -DbuildGUIs=OFF")
message("Disable building TRN software with -DbuildTRN=OFF")
message("Disable building photomosaicing software with -DbuildOpenCV=OFF")
message("Disable supporting GSF format data with -DbuildGSF=OFF")
message("Build Qt-based GUIs with -DbuildQt=ON")
message("Build deprecated programs with -DbuildDeprecated=ON")
message("Disable unit tests with -DbuildTests=OFF (run unit tests with make test)")
message("Specify OTPS install location with -DotpsDir=directory")
message("Print out all CMake variables with -Dverbose=1")
message("----------------------------------------------------------")
# Define minimum CMake version required
cmake_minimum_required(VERSION 3.16)
# Export compile commands for IDE tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Define project
project(MB-System
DESCRIPTION "Open Source software for the processing and display of seafloor mapping data"
HOMEPAGE_URL https://www.mbari.org/technology/mb-system/
LANGUAGES C CXX )
# Disallow in-source builds
get_filename_component (srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component (bindir "${CMAKE_BINARY_DIR}" REALPATH)
if (${srcdir} STREQUAL ${bindir})
message(FATAL_ERROR "In-source builds are not allowed. "
"Please create a directory and run cmake from there, passing the path "
"to this source directory as the last argument. This process created "
"the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}. "
"Please remove them.")
endif (${srcdir} STREQUAL ${bindir})
add_compile_definitions(CMAKE_BUILD_SYSTEM=1)
# Platform system libs commonly tacked onto utility executables. On POSIX:
# libm (math) and pthread are external; on MSVC they're built into the CRT
# and pthreads-win32 is already linked globally.
if(WIN32)
set(MB_SYSLIBS "")
else()
set(MB_SYSLIBS m pthread)
endif()
if (CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBYTESWAPPED")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBYTESWAPPED")
endif()
# MSVC has no <unistd.h>; project ships a stub at include/unistd.h.
# Make it resolvable globally so POSIX-flavoured sources compile on Windows.
if(MSVC)
# Most project libraries have no __declspec(dllexport) markers, so building
# them as SHARED produces a .dll with no .lib import library and downstream
# targets fail to link. Force auto-export of all symbols, which generates
# the import lib automatically. Equivalent to MinGW's --export-all-symbols.
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# NOTE: NOT "BEFORE" — include/ has stale untracked shadows of mb_define.h /
# mb_sapi.h / gsf.h that must not preempt src/mbio etc. POSIX stubs here
# (unistd.h, libgen.h, dirent.h, rpc/) have no MSVC counterparts so they still
# resolve from this dir.
include_directories(${CMAKE_SOURCE_DIR}/include)
# Silence the most common POSIX-name warnings (open vs _open, etc.)
# NOMINMAX prevents Windows.h from defining min/max macros that clobber
# std::numeric_limits<>::max(), std::min(), etc.
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS NOMINMAX WIN32_LEAN_AND_MEAN NOGDI)
# Force-include POSIX compatibility shim (provides clock_gettime, CLOCK_REALTIME, etc.)
# /FI<file> = "include this header at the top of every translation unit".
add_compile_options(/FI${CMAKE_SOURCE_DIR}/include/mb_win_compat.h)
# getopt (POSIX) — utilities pervasively call getopt; MSVC ships none.
if(GETOPT_INCLUDE_DIR)
include_directories(${GETOPT_INCLUDE_DIR})
endif()
if(GETOPT_LIBRARY)
link_libraries(${GETOPT_LIBRARY})
endif()
# NetCDF — GMT public headers (gmt_shore.h etc) include <netcdf.h>.
if(NetCDF_INCLUDE_DIR)
include_directories(${NetCDF_INCLUDE_DIR})
endif()
# GLib (needed by GMT public headers when HAVE_GLIB_GTHREAD set).
if(GLIB_INCLUDE_DIR)
include_directories(${GLIB_INCLUDE_DIR})
endif()
if(GLIB_CONFIG_DIR)
include_directories(${GLIB_CONFIG_DIR})
endif()
if(GLIB_LIBRARY)
link_libraries(${GLIB_LIBRARY})
endif()
# pthreads-win32 (path supplied via PTHREADINC / PTHREADLIB in ConfigUser.cmake).
# Wire include path + global link library so every target that uses pthread_*
# resolves it without per-target plumbing.
if(PTHREADINC)
include_directories(${PTHREADINC})
# PTW32_STATIC_LIB only when linking the static variant (pthreadVC2.lib here
# is the DLL import lib, so leave it dynamic).
add_compile_definitions(HAVE_STRUCT_TIMESPEC)
endif()
if(PTHREADLIB)
link_libraries(${PTHREADLIB})
endif()
# Winsock — htonl/ntohl and friends live in Ws2_32.lib on Windows.
link_libraries(Ws2_32)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build-utils")
option(BUILD_SHARED_LIBS "Build and link with shared libraries" ON)
option(buildGSF "build GSF library" ON)
option(buildGUIs "build graphical tools" ON)
option(buildOpenCV "build OpenCV tools" ON)
option(buildTRN "build MBTRN tools" ON)
option(buildTRNLCM "build MBTRN LCM tools" OFF)
option(buildTrnNoRand "build with TRN_NORAND (random seed disabled)" OFF)
option(buildPCL "build point-cloud-library tools" OFF)
option(buildQt "build Qt tools" OFF)
option(buildTests "build unit tests exercised by make test" ON)
if (DEFINED CACHE{otpsDir})
set(otpsDir $CACHE{otpsDir})
else()
set(otpsDir "/usr/local/src/otps")
endif()
if(APPLE)
execute_process(
COMMAND sw_vers -productVersion
OUTPUT_VARIABLE MACOS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
find_program(MACOS_HAVE_HOMEBREW NAMES brew)
find_program(MACOS_HAVE_MACPORTS NAMES port)
if(${MACOS_VERSION} VERSION_LESS "16")
if (MACOS_HAVE_MACPORTS)
set(MACOS_USE_MACPORTS TRUE)
set(MACOS_USE_HOMEBREW FALSE)
elseif (MACOS_HAVE_HOMEBREW)
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW TRUE)
else()
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW FALSE)
endif()
message("MacOS 15 Sequoia or prior detected")
else()
if (MACOS_HAVE_HOMEBREW)
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW TRUE)
elseif (MACOS_HAVE_MACPORTS)
set(MACOS_USE_MACPORTS TRUE)
set(MACOS_USE_HOMEBREW FALSE)
else()
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW FALSE)
endif()
message("MacOS 26 Tahoe or later detected")
endif()
if(MACOS_HAVE_HOMEBREW)
message("MacOS: package manager Homebrew is installed")
endif()
if(MACOS_HAVE_MACPORTS)
message("MacOS: package manager MacPorts is installed")
endif()
if(MACOS_USE_HOMEBREW)
message("MacOS: using packages installed with Homebrew")
endif()
if(MACOS_USE_MACPORTS)
message("MacOS: using packages installed with MacPorts")
endif()
message("----------------------------------------------------------")
endif()
set(CMAKE_INSTALL_SHARE share)
set(CMAKE_INSTALL_MANPAGES share/man)
set(CMAKE_INSTALL_DOC share/doc)
set(levitusDir "share/mbsystem")
include(GNUInstallDirs)
include(CTest)
# uninstall target
if(NOT TARGET uninstall)
add_custom_target(uninstall COMMAND xargs rm -vf < install_manifest.txt)
endif()
# set RPATH
if (NOT CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
# Libraries
if(buildGSF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_GSF")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_GSF")
add_subdirectory(src/gsf)
endif()
add_subdirectory(src/mbaux)
add_subdirectory(src/mbbitpack)
add_subdirectory(src/mbio)
add_subdirectory(src/bsio)
add_subdirectory(src/surf)
# GMT modules
add_subdirectory(src/gmt)
# Executables
add_subdirectory(src/utilities)
add_subdirectory(src/macros)
add_subdirectory(src/mbgrd2gltf)
add_subdirectory(src/mbmesh)
add_subdirectory(src/otps)
if(buildGUIs)
add_subdirectory(src/mbview)
add_subdirectory(src/mbedit)
add_subdirectory(src/mbgrdviz)
add_subdirectory(src/mbeditviz)
add_subdirectory(src/mbnavadjust)
add_subdirectory(src/mbnavedit)
add_subdirectory(src/mbvelocitytool)
endif()
if(buildOpenCV)
add_subdirectory(src/photo)
endif()
if(buildTRN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTRN_USE_PROJ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRN_USE_PROJ")
add_subdirectory(src/mbtrnframe)
add_subdirectory(src/mbtrn)
add_subdirectory(src/mbtrnav)
add_subdirectory(src/mbtrnutils)
if(buildTRNLCM)
add_subdirectory(src/mbtrnav/opt/rov)
endif()
endif()
if(buildQt)
add_subdirectory(src/qt-guilib)
add_subdirectory(src/qt-mbgrdviz)
add_subdirectory(src/qt-mbgrdviz-3)
add_subdirectory(src/qt-mbedit)
add_subdirectory(src/qt-mbedit-widgets)
add_subdirectory(src/pointCloudEditor)
endif()
if(buildDeprecated)
add_subdirectory(src/deprecated)
endif()
if(buildTests)
add_subdirectory(third_party)
add_subdirectory(test/mbio)
add_subdirectory(test/utilities)
if(buildDeprecated)
add_subdirectory(test/deprecated)
endif()
endif()
add_subdirectory(src/man)
add_subdirectory(src/html)
add_subdirectory(src/share)
message("----------------------------------------------------------")
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message("CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
if(APPLE)
message("MacOS Version: ${MACOS_VERSION}")
if(${MACOS_VERSION} VERSION_LESS "16")
message("MacOS Sequoia or earlier")
else()
message("MacOS Tahoe or later")
endif()
if(MACOS_USE_HOMEBREW)
message("MacOS: Homebrew used")
else()
message("MacOS: Homebrew not used")
endif()
if(MACOS_USE_MACPORTS)
message("MacOS: MacPorts used")
else()
message("MacOS: MacPorts not used")
endif()
endif()
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message("CMAKE_INSTALL_FULL_LIBDIR: ${CMAKE_INSTALL_FULL_LIBDIR}")
message("CMAKE_INSTALL_FULL_INCLUDEDIR: ${CMAKE_INSTALL_FULL_INCLUDEDIR}")
message("CMAKE_INSTALL_FULL_BINDIR: ${CMAKE_INSTALL_FULL_BINDIR}")
message("CMAKE_INSTALL_FULL_DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}")
message("CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}")
message("CMAKE_INSTALL_FULL_DATAROOTDIR: ${CMAKE_INSTALL_FULL_DATAROOTDIR}")
message("CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")
message("CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
message("CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
message("BYTESWAPPED: ${BYTESWAPPED}")
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message("CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}")
if(APPLE)
message("CMAKE_MACOSX_RPATH: ${CMAKE_MACOSX_RPATH}")
endif()
message(OTPS directory: ${otpsDir})
# For debugging: print all set variables
message("----------------------------------------------------------")
if (verbose)
message("All CMake variables:")
message(" ")
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
message("----------------------------------------------------------")
endif()