-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·266 lines (225 loc) · 10.5 KB
/
CMakeLists.txt
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
###############################################################################
#
# CMake build scripts for SPDPointsViewer
#
# Created 2011/03/12 by Peter Bunting
#
# These scripts were initial based on those used for SPDLib
#
# History
# 2011/03/12 - Created by Peter Bunting
#
###############################################################################
###############################################################################
# Set Project name and version
project (SPDPointsViewer)
set (PROJECT_SOURCE_DIR src)
# The version number.
set (SPDPV_VERSION_MAJOR 3)
set (SPDPV_VERSION_MINOR 0)
set (SPDPV_VERSION_PATCH 2)
set (SPDPV_VERSION "${SPDPV_VERSION_MAJOR}.${SPDPV_VERSION_MINOR}.${SPDPV_VERSION_PATCH}")
set (SPDPV_PACKAGE_VERSION "${SPDPV_VERSION_MAJOR}.${SPDPV_VERSION_MINOR}.${SPDPV_VERSION_PATCH}")
set (SPDPV_PACKAGE_STRING "SPDPV ${SPDPV_VERSION_MAJOR}.${SPDPV_VERSION_MINOR}.${SPDPV_VERSION_PATCH}")
set (SPDPV_PACKAGE_BUGREPORT "[email protected]")
set (SPDPV_PACKAGE "SPDPointsViewer")
set (SPDPV_PACKAGE "SPDPV")
set(SPDLIB_IO_INCLUDE_DIR /usr/local/include CACHE PATH "Include PATH for SPDLibIO")
set(SPDLIB_IO_LIB_PATH /usr/local/lib CACHE PATH "Library PATH for SPDLibIO")
set(HDF5_INCLUDE_DIR /usr/local/include CACHE PATH "Include PATH for HDF5")
set(HDF5_LIB_PATH /usr/local/lib CACHE PATH "Library PATH for HDF5")
set(BOOST_INCLUDE_DIR /usr/local/include CACHE PATH "Include PATH for Boost")
set(BOOST_LIB_PATH /usr/local/lib CACHE PATH "Library PATH for Boost")
set(GDAL_INCLUDE_DIR /usr/local/include CACHE PATH "Include PATH for GDAL")
set(GDAL_LIB_PATH /usr/local/lib CACHE PATH "Library PATH for GDAL")
#set(QT5_INCLUDE_DIR /usr/local/include CACHE PATH "Include PATH for GDAL")
#set(QT5_LIB_PATH /usr/local/lib CACHE PATH "Library PATH for GDAL")
set(SPDPV_APP SPDPointsViewer)
###############################################################################
###############################################################################
# CMake settings
cmake_minimum_required(VERSION 3.12)
IF(NOT CMAKE_BUILD_TYPE)
#SET(CMAKE_BUILD_TYPE "DEBUG")
SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
set(CMAKE_COLOR_MAKEFILE ON)
# Allow advanced users to generate Makefiles printing detailed commands
mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)
# Path to additional CMake modules
set(CMAKE_MODULE_PATH ./cmake/modules ${CMAKE_MODULE_PATH})
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
###############################################################################
###############################################################################
# Documentation
file(READ "doc/index.txt" README )
file(WRITE "README.txt" "${README}")
###############################################################################
###############################################################################
# Platform and compiler specific settings
if(WIN32)
if (MSVC)
if (MSVC80 OR MSVC90 OR MSVC10 OR MSVC14)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNING)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W2"
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2")
endif()
# Generate dot-user file with user-specific settings for Visual Studio project
set(MSVC_ENVIRONMENT_PATH "" CACHE STRING
"Custom PATH for Environment property in Visual Studio project configuration")
mark_as_advanced(MSVC_ENVIRONMENT_PATH)
set(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG "${ENVIRONMENT_PATH}")
mark_as_advanced(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG)
# Use cmake's MSVC_VERSION to work out the name of the Boost/CGAL DLL's
# to use (they use a different numbering scheme from cmake)
set(MSVC_STRING_1500 "vc90")
set(MSVC_STRING_1600 "vc100")
set(MSVC_STRING_1700 "vc110")
set(MSVC_STRING_1800 "vc120")
set(MSVC_STRING_1900 "vc140")
set(MSVC_STRING ${MSVC_STRING_${MSVC_VERSION}})
message(STATUS "Using MSVC String " ${MSVC_STRING})
endif()
else()
# Recommended C++ compilation flags
set(SPDPV_COMMON_CXX_FLAGS "-Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wredundant-decls -Wno-long-long -DNDEBUG")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ${SPDPV_COMMON_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -D_GLIBCXX_USE_CXX14_ABI=0")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SPDPV_COMMON_CXX_FLAGS} -std=c++14")
endif()
endif(WIN32)
#IF( APPLE )
# SET( PROGNAME SPDPointsViewer )
# SET( MACOSX_BUNDLE_BUNDLE_NAME SPDPointsViewer)
# SET( MACOSX_BUNDLE_INFO_STRING "SPD Points Viewer")
# SET( MACOSX_BUNDLE_ICON_FILE SPDPointsViewer.icns )
# SET( MACOSX_FILE_ICON_FILE SPD.icns )
# SET( MACOSX_BUNDLE_SHORT_VERSION_STRING 2.01-beta1 )
# SET( MACOSX_BUNDLE_BUNDLE_VERSION 2.01-beta1 )
# SET( MACOSX_BUNDLE_LONG_VERSION_STRING Version 2.01-beta1 )
# SET( CMAKE_OSX_ARCHITECTURES x86_64 ) #Comment out if not universal binary
# SET( MACOSX_BUNDLE_COPYRIGHT "Copyright Pete Bunting")
# SET( MACOSX_BUNDLE_GUI_IDENTIFIER "org.spdlib.spdpointsviewer")
# ELSE( APPLE )
# SET( PROGNAME SPDPointsViewer )
# ENDIF( APPLE )
SET( PROGNAME SPDPointsViewer)
###############################################################################
###############################################################################
# Check the required libraries are present
if (MSVC)
# Under Windows, the boost libs are strangely named - use glob to find them
file(GLOB BOOST_FS_LIB ${BOOST_LIB_PATH}/libboost_filesystem-${MSVC_STRING}-*.lib )
if(NOT BOOST_FS_LIB)
message(FATAL_ERROR "Could not find boost_filesystem lib")
endif()
file(GLOB BOOST_SYS_LIB ${BOOST_LIB_PATH}/libboost_system-${MSVC_STRING}-*.lib )
if(NOT BOOST_SYS_LIB)
message(FATAL_ERROR "Could not find boost_system lib")
endif()
message(STATUS "Found boost libraries " ${BOOST_FS_LIB} ${BOOST_SYS_LIB})
set(BOOST_LIBRARIES -LIBPATH:${BOOST_LIB_PATH} ${BOOST_FS_LIB} ${BOOST_SYS_LIB})
else()
set(BOOST_LIBRARIES -L${BOOST_LIB_PATH} -lboost_filesystem -lboost_system)
endif(MSVC)
include_directories(${GDAL_INCLUDE_DIR})
if (MSVC)
set(GDAL_LIBRARIES -LIBPATH:${GDAL_LIB_PATH} gdal_i.lib)
else()
set(GDAL_LIBRARIES -L${GDAL_LIB_PATH} -lgdal)
endif(MSVC)
include_directories(${HDF5_INCLUDE_DIR})
if (MSVC)
set(HDF5_LIBRARIES -LIBPATH:${HDF5_LIB_PATH} hdf5dll.lib hdf5_cppdll.lib)
else()
set(HDF5_LIBRARIES -L${HDF5_LIB_PATH} -lhdf5 -lhdf5_hl -lhdf5_cpp)
endif(MSVC)
include_directories(${SPDLIB_IO_INCLUDE_DIR})
if(MSVC)
set(SPDLIB_LIBRARY -LIBPATH:${SPDLIB_IO_LIB_PATH} libspdio.lib)
else()
set(SPDLIB_LIBRARY -L${SPDLIB_IO_LIB_PATH} -lspdio )
endif(MSVC)
find_package(OpenGL REQUIRED)
if (OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
endif(OPENGL_FOUND)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
# Add the include directories for the Qt 5 modules to the compile lines.
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
# Use the compile definitions defined in the Qt 5 modules
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Gui_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5OpenGL_DEFINITIONS})
###############################################################################
###############################################################################
# Build Application
SET( SPDPV_SRCS
${PROJECT_SOURCE_DIR}/main.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerException.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewer.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerColourTable.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerCreateOverviewImage.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerApplication.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerOverviewWidget.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewer3DWidget.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerPreferences.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerDisplayProfile.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerConvertDialog.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerControl.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerReadPTXTMeshFile.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerLoadOverviewImage.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerLoad3DData.cpp
${PROJECT_SOURCE_DIR}/SPDPointsViewerSubsetDialog.cpp
)
SET( SPDPV_HDRS
${PROJECT_SOURCE_DIR}/SPDPointsViewerCommon.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerException.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerCreateOverviewImage.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerReadPTXTMeshFile.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerColourTable.h
${PROJECT_SOURCE_DIR}/SPDPointsViewer.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerApplication.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerOverviewWidget.h
${PROJECT_SOURCE_DIR}/SPDPointsViewer3DWidget.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerPreferences.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerDisplayProfile.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerConvertDialog.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerControl.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerLoadOverviewImage.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerLoad3DData.h
${PROJECT_SOURCE_DIR}/SPDPointsViewerSubsetDialog.h
)
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
IF(WIN32)
# make GUI rather than console (suppresses console window) and add icon
ADD_EXECUTABLE( ${PROGNAME} WIN32 ${SPDPV_SRCS} ${PROJECT_SOURCE_DIR}/SPDPointsViewer.rc)
ELSE()
ADD_EXECUTABLE( ${PROGNAME} ${SPDPV_SRCS} ${SPDPV_HDRS} )
ENDIF( WIN32 )
#qt5_use_modules(${PROGNAME} Widgets OpenGL)
TARGET_LINK_LIBRARIES( ${PROGNAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL ${SPDLIB_LIBRARY} ${GDAL_LIBRARIES} ${BOOST_LIBRARIES} ${GLUT_LIBRARY} ${OPENGL_LIBRARIES})
###############################################################################
# Installation
install(TARGETS ${PROGNAME} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)