-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
292 lines (253 loc) · 9.38 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
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
cmake_minimum_required (VERSION 3.21)
project (Geoflow VERSION 0.3.6)
include(GNUInstallDirs)
set(GF_PLUGIN_FOLDER "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/geoflow-plugins" CACHE STRING "Geoflow plugin folder")
set(GF_PLUGIN_FOLDER_INSTALL "${GF_PLUGIN_FOLDER}")
if(PROJECT_IS_TOP_LEVEL)
if (WIN32)
string(REPLACE "\\" "\\\\" GF_PLUGIN_FOLDER ${GF_PLUGIN_FOLDER})
string(REPLACE "\\" "\\\\" GF_PLUGIN_FOLDER_INSTALL ${GF_PLUGIN_FOLDER})
endif()
else()
if (WIN32)
set(GF_PLUGIN_FOLDER_INSTALL "lib\\geoflow-plugins" PARENT_SCOPE ) # this needs to be a relative to the installed geof.exe
set(GF_PLUGIN_FOLDER_INSTALL "lib\\geoflow-plugins" ) # this needs to be a relative to the installed geof.exe
set(GF_PLUGIN_FOLDER "..\\lib\\geoflow-plugins" )
string(REPLACE "\\" "\\\\" GF_PLUGIN_FOLDER ${GF_PLUGIN_FOLDER})
string(REPLACE "\\" "\\\\" GF_PLUGIN_FOLDER_INSTALL ${GF_PLUGIN_FOLDER})
else()
set(GF_PLUGIN_FOLDER_INSTALL "${GF_PLUGIN_FOLDER}" PARENT_SCOPE)
endif()
endif()
option(GF_BUILD_GUI "Build the GUI components of geoflow" TRUE)
option(GF_BUILD_GUI_FILE_DIALOGS "Build GUI with OS native file dialogs" TRUE)
# dependencies
add_subdirectory(thirdparty)
find_package(nlohmann_json 3.10.5 CONFIG REQUIRED)
if (WIN32) # vcpkg doesn't work when there is a version number here
find_package(PROJ REQUIRED CONFIG)
else()
find_package(PROJ 9.0.0 REQUIRED CONFIG)
endif()
set(PROJ_DATA_DIR CACHE PATH ${PROJ_DIR})
if(GF_BUILD_GUI)
find_package(glfw3 3.3 REQUIRED)
#message(STATUS "GLFW libs: ${GLFW_LIBRARIES}")
endif()
# set(THREADS_PREFER_PTHREAD_FLAG ON)
# find_package(Threads)
# DLLoader
if (WIN32)
include_directories(
src/DLLoader/Windows/
)
endif(WIN32)
if(UNIX)
include_directories(
src/DLLoader/Unix/
)
# set (CMAKE_CXX_FLAGS "-W -Wall -Wextra")
endif(UNIX)
# definitions
set(GF_SHADER_PATH ${CMAKE_INSTALL_PREFIX}/share/geoflow)
if(WIN32)
set(GF_SHADER_PATH "bin\\share")
add_definitions(
-DGF_SHADER_PATH=\"share\"
)
else()
add_definitions(
-DGF_SHADER_PATH=\"${GF_SHADER_PATH}\"
)
endif()
add_definitions(
-DGLFW_INCLUDE_NONE
-DIMGUI_IMPL_OPENGL_LOADER_GLAD
-DGLM_FORCE_CTOR_INIT
)
if(MSVC)
add_definitions(-DNOMINMAX)
endif()
if(GF_BUILD_GUI)
add_definitions(-DGF_BUILD_GUI)
endif()
if(GF_BUILD_GUI_FILE_DIALOGS)
add_definitions(-DGF_BUILD_GUI_FILE_DIALOGS)
endif()
# version
configure_file(cmake/version.h ${PROJECT_BINARY_DIR}/version.h)
# includes
include_directories(
src
thirdparty/filesystem/include
thirdparty/exprtk
${PROJECT_BINARY_DIR}
)
# targets
add_library(geoflow-core SHARED
src/geoflow/geoflow.cpp
src/geoflow/common.cpp
src/geoflow/parameters.cpp
# src/geoflow/api.cpp
src/geoflow/AttributeCalcNode.cpp
src/geoflow/ExpressionComputer.cpp
src/geoflow/projHelper.cpp
)
target_link_libraries(geoflow-core PRIVATE nlohmann_json::nlohmann_json PROJ::proj)
set_target_properties(geoflow-core PROPERTIES
CXX_STANDARD 17
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
)
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
target_compile_options(geoflow-core PUBLIC "/Zc:__cplusplus" PRIVATE /bigobj)
endif()
if(${GF_BUILD_GUI})
include_directories(
thirdparty/glad/include
thirdparty/imgui
thirdparty/imgui/examples
)
set(GF_SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/shaders/crosshair.frag
${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/shaders/crosshair.vert
${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/shaders/basic.frag
${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/shaders/basic.vert)
SET(GF_GUI_SOURCES
src/viewer/app.cpp
src/viewer/app_povi.cpp
thirdparty/glad/src/glad.c
src/viewer/gloo.cpp
thirdparty/imgui/imgui.cpp
thirdparty/imgui/misc/cpp/imgui_stdlib.cpp
thirdparty/imgui/imgui_draw.cpp
thirdparty/imgui/imgui_widgets.cpp
thirdparty/imgui/imgui_demo.cpp
thirdparty/imgui/examples/imgui_impl_glfw.cpp
thirdparty/imgui/examples/imgui_impl_opengl3.cpp
src/geoflow/gui/ImNodes.cpp
src/geoflow/gui/ImNodesEz.cpp
src/geoflow/gui/imgui_color_gradient.cpp
src/geoflow/gui/parameter_widgets.cpp
)
SET(GF_FILEDIALOG_LIBS "")
if(GF_BUILD_GUI_FILE_DIALOGS)
SET(GF_GUI_SOURCES
${GF_GUI_SOURCES}
thirdparty/osdialog/osdialog.c
src/geoflow/gui/osdialog.cpp
)
include_directories(
thirdparty/osdialog
)
if(APPLE)
SET(GF_GUI_SOURCES ${GF_GUI_SOURCES}
thirdparty/osdialog/osdialog_mac.m)
SET(GF_FILEDIALOG_LIBS ${GF_FILEDIALOG_LIBS}
"-framework AppKit")
elseif(MSVC)
SET(GF_GUI_SOURCES ${GF_GUI_SOURCES}
thirdparty/osdialog/osdialog_win.c)
SET(GF_FILEDIALOG_LIBS ${GF_FILEDIALOG_LIBS}
comdlg32)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
SET(GF_GUI_SOURCES ${GF_GUI_SOURCES}
thirdparty/osdialog/osdialog_gtk2.c)
SET(GF_FILEDIALOG_LIBS ${GF_FILEDIALOG_LIBS}
${GTK2_LIBRARIES})
include_directories(${GTK2_INCLUDE_DIRS})
endif()
endif(GF_BUILD_GUI_FILE_DIALOGS)
add_library(geoflow-gui STATIC ${GF_GUI_SOURCES})
# target_include_directories(geoflow-gui nlohmann_json::nlohmann_json)
target_link_libraries(geoflow-gui PRIVATE geoflow-core glfw ${GF_FILEDIALOG_LIBS})
target_include_directories(geoflow-gui PRIVATE ${GLM_INCLUDE_DIRECTORIES})
set_target_properties(geoflow-gui PROPERTIES CXX_STANDARD 17)
if (WIN32)
get_target_property(GLFW_DLL_LOCATION glfw IMPORTED_LOCATION_RELEASE)
message("GLFW DLL: ${GLFW_DLL_LOCATION}")
install(FILES ${GLFW_DLL_LOCATION} DESTINATION bin)
endif (WIN32)
endif()
# installation
# ensure rpath is set up properly (https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_definitions(-DGF_PLUGIN_FOLDER=\"${GF_PLUGIN_FOLDER}\")
message(STATUS "Geoflow plugin folder set to ${GF_PLUGIN_FOLDER}")
message(STATUS "Geoflow plugin folder install set to ${GF_PLUGIN_FOLDER_INSTALL}")
set(GF_PLUGIN_EXTENSION ".so")
if (WIN32)
set(GF_PLUGIN_EXTENSION ".dll")
endif()
message(STATUS "Setting Geoflow plugin extension to ${GF_PLUGIN_EXTENSION}")
add_definitions(-DGF_PLUGIN_EXTENSION=\"${GF_PLUGIN_EXTENSION}\")
# write the hash of the concatenated shared header files to a new header file, so that we can check compatibility between main geof executable and the plugins
set(GF_SHH_FILE ${CMAKE_BINARY_DIR}/include/geoflow/gfSharedHeadersHash.h)
if(PROJECT_IS_TOP_LEVEL)
add_custom_command(
TARGET geoflow-core
COMMAND ${CMAKE_COMMAND} -DOUTPUT_FILE=${GF_SHH_FILE} -DPROJECT_SOURCE_DIR=${CMAKE_CURRENT_LIST_DIR} -P "${CMAKE_CURRENT_LIST_DIR}/cmake/ComputeSharedHeadersHash.cmake"
)
else()
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/common.hpp s1)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/parameters.hpp s2)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/geoflow.hpp s3)
string(CONCAT GF_SHARED_HEADERS ${s1} ${s2} ${s3})
string(MD5 GF_SHARED_HEADERS_HASH ${GF_SHARED_HEADERS})
message(STATUS "Setting Geoflow shared header hash to ${GF_SHARED_HEADERS_HASH}")
file(WRITE ${GF_SHH_FILE} "#define GF_SHARED_HEADERS_HASH \"${GF_SHARED_HEADERS_HASH}\"\n")
endif()
set_property(TARGET geoflow-core PROPERTY PUBLIC_HEADER
src/geoflow/common.hpp
src/geoflow/parameters.hpp
src/geoflow/geoflow.hpp
src/geoflow/api.hpp
src/geoflow/projHelper.hpp
${GF_SHH_FILE}
)
# target_include_directories(geoflow-core PUBLIC
# ${CMAKE_BINARY_DIR}/include
# )
# target_sources(geoflow-core PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/common.hpp>
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/parameters.hpp>
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoflow/geoflow.hpp>
# $<BUILD_INTERFACE:${GF_SHH_FILE}>
# $<INSTALL_INTERFACE:include/geoflow/common.hpp>
# $<INSTALL_INTERFACE:include/geoflow/parameters.hpp>
# $<INSTALL_INTERFACE:include/geoflow/geoflow.hpp>
# $<INSTALL_INTERFACE:include/geoflow/gfSharedHeadersHash.h>
# )
install(TARGETS geoflow-core EXPORT geoflow-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geoflow)
install(EXPORT geoflow-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geoflow)
include ( CMakePackageConfigHelpers )
configure_package_config_file(cmake/geoflow-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/geoflow-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geoflow
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/geoflow-config.cmake
cmake/gf_plugin.cpp.in
cmake/geoflow_create_plugin.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/geoflow)
install(FILES LICENSE DESTINATION share/geoflow)
# install proj.db and rasters for Dutch rijksdriehoekstelsel
if(WIN32)
install(FILES ${PROJ_DATA_DIR}/proj.db DESTINATION share/proj)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources/ DESTINATION share/proj FILES_MATCHING PATTERN "*.tif")
endif(WIN32)
add_subdirectory(apps)
include(cmake/geoflow_create_plugin.cmake)