forked from SatDump/SatDump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
304 lines (252 loc) · 12.2 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
293
294
295
296
297
298
299
300
301
302
303
304
cmake_minimum_required(VERSION 3.12)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(CheckCXXSourceCompiles)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
endif()
project(SatDump)
option(BUILD_GUI "Build the GUI" ON)
option(BUILD_TESTING "Build the testing program" OFF)
option(BUILD_TOOLS "Build the tools programs" OFF)
option(BUILD_ZIQ "Build support for the custom ZIQ format" ON)
option(BUILD_ZIQ2 "Build support for the custom ZIQ2 format (Very WIP)" OFF)
option(BUILD_MSVC "Build for Windows with MSVC" OFF) # Seems like "MSVC" as a macro messed up below for some reason...
option(BUILD_OPENCL "Build with OpenCL GPU Accelerations" ON)
option(BUILD_OPENMP "Build with OpenMP Optimizations" ON)
option(ENABLE_INSTALL "Enable INSTALL TARGET" ON)
if(ANDROID)
# Build settings
set(BUILD_OPENCL OFF)
set(BUILD_OPENMP OFF)
endif()
# Set default install prefix to /usr
if(UNIX)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(APPLE)
set(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH "Set CMAKE Default to /usr/local" FORCE)
else()
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Set CMAKE Default to /usr" FORCE)
endif()
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
if(APPLE)
include_directories(/usr/local/include)
include_directories(/usr/local/opt/jpeg-turbo/include)
include_directories(/usr/local/Cellar/fftw/3.3.9/include)
link_directories(/usr/local/lib)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
include_directories(/opt/homebrew/include/)
link_directories(/opt/homebrew/lib/)
endif()
# Jemalloc
find_package(PkgConfig)
pkg_check_modules(JEMALLOC jemalloc)
pkg_search_module(JEMALLOC REQUIRED jemalloc)
include_directories(${JEMALLOC_INCLUDE_DIRS})
link_libraries(${JEMALLOC_LIBRARIES})
endif()
if(UNIX)
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(BUILD_OPENMP)
message("Compiling with OpenMP support!")
if(APPLE)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -I/usr/local/opt/llvm/include -I/opt/homebrew/opt/libomp/include -L/opt/homebrew/opt/libomp/lib")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -I/usr/local/opt/llvm/include -I/usr/local/opt/libomp/include -L/usr/local/opt/libomp/lib")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
endif()
find_package(ZSTD)
if((NOT ZSTD_FOUND) AND BUILD_ZIQ AND(NOT ANDROID))
message("ZIQ Was enabled but libzstd was not found!")
set(BUILD_ZIQ OFF)
endif()
else()
# set(CMAKE_CXX_FLAGS "-Wall")
# set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
endif()
if(MSVC OR BUILD_MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
if(BUILD_OPENMP)
message("Compiling with OpenMP support!")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp")
endif()
# Speed up this to object-level, Suppress type conversion warnings, suppress
# POSIX function warnings, suppress warnings about DLL-exported functions, and
# Suppress warnings about template methods defined in another C++ file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP8 /EHsc /wd4305 /wd4267 /wd4244 /wd4273 /wd4661")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP8 /EHsc /wd4305 /wd4267 /wd4244 /wd4273 /wd4661")
#Suppress pointless (to us) warnings about DLL-exported functions
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4286,4217")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ignore:4286,4217")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4286,4217")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include_directories(vcpkg/installed/x64-windows/include)
link_directories(vcpkg/installed/x64-windows/lib)
endif()
project(SatDump VERSION "1.1.4")
# Check if the current commit has a tag
execute_process(
COMMAND git name-rev --name-only --tags HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HAS_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of current branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Set version
if(GIT_HAS_TAG STREQUAL "undefined")
message("-- Commit has no tag (${GIT_HAS_TAG}). Assume dev build")
set(SATDUMP_VERSION "${PROJECT_VERSION}-${GIT_HASH}")
else()
message("-- Commit has no tag (${GIT_HAS_TAG}). Assume release build")
set(SATDUMP_VERSION "${PROJECT_VERSION}")
endif()
add_compile_definitions(SATDUMP_VERSION="${SATDUMP_VERSION}")
if(ANDROID)
add_compile_definitions(ANDROID_ABI_LIB="${ANDROID_ABI}")
endif()
# Check we have OpenCL
if(MSVC)
set(OPENCL_FOUND 1)
set(OpenCL_LIBRARY OpenCL.dll)
set(OpenCL_LIBRARIES OpenCL.dll)
else()
find_package(OpenCL)
endif()
if(OPENCL_FOUND AND BUILD_OPENCL)
message("OpenCL Found! SatDump will support accelerated GPU computing.")
# add_compile_definitions(USE_OPENCL="1") # This does NOT work with MSVC. Kept anyway for now.
else()
message("OpenCL NOT found or disabled!")
set(BUILD_OPENCL OFF)
endif()
# For good measure
if(BUILD_ZIQ)
message("Building with ZIQ Support")
endif()
if(BUILD_ZIQ2)
message("Building with ZIQ Support")
endif()
# If in debug, set the macro
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(BUILD_IS_DEBUG=1)
message("")
message("██████╗ █████╗ ███╗ ██╗ ██████╗ ███████╗██████╗ ")
message("██╔══██╗██╔══██╗████╗ ██║██╔════╝ ██╔════╝██╔══██╗")
message("██║ ██║███████║██╔██╗ ██║██║ ███╗█████╗ ██████╔╝")
message("██║ ██║██╔══██║██║╚██╗██║██║ ██║██╔══╝ ██╔══██╗")
message("██████╔╝██║ ██║██║ ╚████║╚██████╔╝███████╗██║ ██║")
message("╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝")
message("Building SatDump in Debug mode!")
message("")
endif()
# Check system has <filesystem>
check_cxx_source_compiles("#include <filesystem>\n int main() { return 0; }" STD_HAS_FILESYSTEM)
if(NOT STD_HAS_FILESYSTEM)
include_directories(std_filesystem)
endif()
add_subdirectory(src-core)
add_subdirectory(src-cli)
if(BUILD_GUI)
message("Building the GUI")
add_subdirectory(src-interface)
if(NOT ANDROID)
add_subdirectory(src-ui)
endif()
endif()
if(BUILD_TESTING)
add_subdirectory(src-testing)
endif()
if(BUILD_TOOLS)
add_subdirectory(tools)
endif()
add_subdirectory(plugins)
# Install configuration
if((NOT ANDROID) AND ENABLE_INSTALL)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/pipelines DESTINATION share/satdump)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/resources DESTINATION share/satdump)
install(FILES ${CMAKE_SOURCE_DIR}/satdump_cfg.json DESTINATION share/satdump)
install(FILES ${CMAKE_SOURCE_DIR}/icon.png DESTINATION share/satdump)
configure_file(${CMAKE_SOURCE_DIR}/satdump.desktop ${CMAKE_CURRENT_BINARY_DIR}/satdump.desktop @ONLY)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/satdump.desktop DESTINATION share/applications)
endif()
# Create uninstall target
configure_file(${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY)
add_custom_target(uninstall ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# CPack Configuration
set(CPACK_PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "satdump-${PROJECT_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A satellite data processing software" CACHE STRING "")
set(CPACK_PACKAGE_VENDOR "SatDump")
set(CPACK_PACKAGE_CONTACT "Aang23")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libfftw3-bin, libvolk-bin | libvolk2-bin, libpng16-16, libnng1, librtlsdr0 | librtlsdr2, libhackrf0, libairspy0, libairspyhf1, libglfw3 | libglfw3-wayland, libzstd1, libjemalloc2 | libjemalloc1")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libomp5-14, ocl-icd-libopencl1, intel-opencl-icd, mesa-opencl-icd")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
if(MSVC OR BUILD_MSVC)
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
else()
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
endif()
#set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
#set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
#set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${SATDUMP_VERSION})
if(MSVC OR BUILD_MSVC)
# Customize NSIS template
file(READ "${CMAKE_ROOT}/Modules/Internal/CPack/NSIS.template.in" NSIS_template)
set(CREATE_ICONS_REPLACE " SetOutPath \"$INSTDIR\\bin\"\n@CPACK_NSIS_CREATE_ICONS@\n@CPACK_NSIS_CREATE_ICONS_EXTRA@\n SetOutPath \"$INSTDIR\"")
string(CONCAT INSTALLDIR_REPLACE " InstallDir \"@CPACK_NSIS_INSTALL_ROOT@\\@CPACK_PACKAGE_INSTALL_DIRECTORY@\""
"\n InstallDirRegKey HKLM Software\\@CPACK_PACKAGE_VENDOR@\\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@ \"\"")
string(REPLACE "@CPACK_NSIS_CREATE_ICONS@\n@CPACK_NSIS_CREATE_ICONS_EXTRA@" "${CREATE_ICONS_REPLACE}" NSIS_template "${NSIS_template}")
string(REPLACE " InstallDir \"@CPACK_NSIS_INSTALL_ROOT@\\@CPACK_PACKAGE_INSTALL_DIRECTORY@\"" "${INSTALLDIR_REPLACE}" NSIS_template "${NSIS_template}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in" "${NSIS_template}")
set(CPACK_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}")
# Generate Installer
set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_INSTALL_DIRECTORY SatDump)
set(CPACK_NSIS_MANIFEST_DPI_AWARE ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_BRANDING_TEXT "SatDump - General Purpose Satellite Data Processor")
set(CPACK_NSIS_MUI_HEADERIMAGE "${PROJECT_SOURCE_DIR}\\\\windows\\\\installer-header.bmp")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\windows\\\\icon.ico")
if(BUILD_GUI)
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\satdump-ui.exe")
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "satdump-ui" "SatDump")
list(APPEND CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$DESKTOP\\\\SatDump.lnk\\\" \\\"$INSTDIR\\\\bin\\\\satdump-ui.exe\\\"")
list(APPEND CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$DESKTOP\\\\SatDump.lnk\\\"")
endif()
if(PLUGIN_REMOTE_SDR_SUPPORT)
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "satdump_sdr_server" "SatDump SDR Server")
endif()
file(GLOB_RECURSE SATDUMP_WINDOWS_DEPENDENCIES ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/installed/x64-windows/bin/*.dll)
install(FILES ${SATDUMP_WINDOWS_DEPENDENCIES} DESTINATION bin)
install(TARGETS satdump_core DESTINATION bin)
else()
set(CPACK_GENERATOR DEB)
#set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEB_COMPONENT_INSTALL ON)
endif()
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
include(CPack)
endif()