-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
480 lines (435 loc) · 17.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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
cmake_minimum_required(VERSION 3.2)
project(ginga)
include(CMakeLists.defs.txt)
cmake_policy(SET CMP0087 NEW)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wno-deprecated-declarations)
# set all target runtime to CMAKE_BINARY_DIR
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# ------------------------
# required deps
# ------------------------
find_package(GLIB 2.32 REQUIRED COMPONENTS gobject gio gthread gmodule)
find_package(LibSoup 2.4 REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GDK3 REQUIRED)
find_package(Cairo REQUIRED)
find_package(Fontconfig REQUIRED)
find_package(Pango REQUIRED)
find_package(RSVG REQUIRED)
find_package(GStreamer 1.0 REQUIRED)
find_package(GTK3 REQUIRED)
find_package(ATK REQUIRED)
pkg_check_modules(JSON jsoncpp REQUIRED)
find_package(Lua 5.3 REQUIRED)
pkg_check_modules(GSSDP gssdp-1.2 REQUIRED)
option(WITH_NCLUA_BUILD "Download and build nclua." OFF)
if(WITH_NCLUA_BUILD)
# nclua download/configure/build/install
include(ExternalProject)
ExternalProject_Add(nclua_build
GIT_REPOSITORY "https://github.com/telemidia/nclua.git"
GIT_TAG master
UPDATE_COMMAND ""
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/nclua
CONFIGURE_COMMAND <SOURCE_DIR>/bootstrap &&
<SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
--without-nclua-gst
BUILD_COMMAND make
INSTALL_COMMAND make install
)
ExternalProject_Get_Property(nclua_build install_dir)
set(NCLUA_INCLUDE_DIRS "${install_dir}/include")
set(NCLUA_LIBRARIES "${install_dir}/lib/libnclua.a")
link_directories("${install_dir}/lib")
else()
PKG_CHECK_MODULES(NCLUA nclua REQUIRED)
endif()
# ------------------------
# optional targets
# ------------------------
option(WITH_CEF "Build with chromium embedded support." OFF)
option(WITH_OPENGL "Build Ginga with opengl support." OFF)
option(WITH_GINGAQT "Build nclcomposer's ginga plugin." OFF)
if(WITH_OPENGL)
find_package(SDL2)
find_package(OpenGL)
set(WITH_OPENGL ON)
else()
set(WITH_OPENGL OFF) # openGL not found, turn it off
endif()
if(WITH_CEF)
# CEF download/configure/build/install
set(CEF_VERSION cef_binary_3.3029.1619.geeeb5d7_linux64_minimal)
set(CEF_SHA1 f809ce65b0b532fcbba6cec5f0e60f731fd3cbbd)
set(CEF_FILE ${CEF_VERSION}.tar.bz2)
set(CEF_URL http://opensource.spotify.com/cefbuilds/${CEF_FILE})
set(CEF_LOCAL_PATH ${CMAKE_BINARY_DIR}/3rdparty)
set(CEF_LOCAL_FILE ${CMAKE_BINARY_DIR}/3rdparty/${CEF_FILE}.tar.gz)
if(NOT EXISTS "${CEF_LOCAL_FILE}")
message(STATUS "-- Downloading chromium embedded binary package...")
file(DOWNLOAD ${CEF_URL} ${CEF_LOCAL_FILE}
EXPECTED_HASH SHA1=${CEF_SHA1}
SHOW_PROGRESS)
message(STATUS "-- Extracting chromium embedded files...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${CEF_LOCAL_FILE}
WORKING_DIRECTORY ${CEF_LOCAL_PATH}
)
endif()
set(CEF_ROOT "${CEF_LOCAL_PATH}/${CEF_VERSION}/")
find_package(CEF REQUIRED)
add_subdirectory(${CEF_ROOT}/libcef_dll libcef_dll_bin)
# logical target used to link the libcef library.
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
set(WITH_CEF ON)
endif()
if(WITH_OPENGL)
list(APPEND LIBGINGA_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND LIBGINGA_LIBS ${OPENGL_LIBRARIES})
endif()
if(WITH_OPENGL)
add_executable(ginga-gl src/ginga-gl.cpp)
target_include_directories(ginga-gl PRIVATE
${SDL2_INCLUDE_DIR}
)
target_link_libraries(ginga-gl PRIVATE
libginga
${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
)
endif()
# optional ginga-qt target
if(WITH_GINGAQT)
set(CMAKE_INCLUDE_CURRENTDIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# find the QtWidgets library
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
add_executable(ginga-qt
./src/ginga-qt.cpp
)
target_link_libraries(ginga-qt
Qt5::Core
Qt5::Widgets
libginga
)
target_compile_definitions(ginga-qt PRIVATE -DQT_NO_KEYWORDS)
target_include_directories(ginga-qt PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${LIBGINGA_INCLUDE_DIRS}
)
endif()
if(WITH_CEF)
# Copy binary and resource files to the target output directory.
COPY_FILES(ginga "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
COPY_FILES(ginga "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
# Set SUID permissions on the chrome-sandbox target.
SET_LINUX_SUID_PERMISSIONS(ginga "${CEF_TARGET_OUT_DIR}/chrome-sandbox")
endif()
# ------------------------
# ginga and gingagui targets
# ------------------------
# tests use TOP_SRCDIR and ABS_TOP_SRCDIR
set(TOP_SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/")
set(ABS_TOP_SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/")
# libginga
set(LIBGINGA_SOURCES
./lib/ginga.h
./lib/aux-ginga.cpp
./lib/aux-gl.cpp
./lib/Composition.cpp
./lib/Context.cpp
./lib/Document.cpp
./lib/Event.cpp
./lib/Formatter.cpp
./lib/Ginga.cpp
./lib/Media.cpp
./lib/MediaSettings.cpp
./lib/Object.cpp
./lib/Parser.cpp
./lib/ParserLua.cpp
./lib/Predicate.cpp
./lib/Switch.cpp
./lib/Player.cpp
./lib/PlayerAnimator.cpp
./lib/PlayerImage.cpp
./lib/PlayerLua.cpp
./lib/PlayerSigGen.cpp
./lib/PlayerText.cpp
./lib/PlayerVideo.cpp
./lib/PlayerRemote.cpp
./lib/PlayerSvg.cpp
./lib/WebServices.cpp
)
if(WITH_CEF)
list(APPEND LIBGINGA_SOURCES ./lib/player/HTMLPlayer.cpp )
list(APPEND GINGA_INCLUDE_DIRS ${CEF_ROOT} ${CEF_ROOT}/include)
list(APPEND GINGA_LIBS libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
endif()
set(LIBGINGA_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/lib/
${GLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${GDKPIXBUF_INCLUDE_DIRS}
${GDK3_INCLUDE_DIRS}
${ATK_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}
${FONTCONFIG_INCLUDE_DIR}
${PANGO_INCLUDE_DIRS}
${RSVG_INCLUDE_DIRS}
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_BASE_INCLUDE_DIRS}
${LIBSOUP_INCLUDE_DIRS}
${GSSDP_INCLUDE_DIRS}
${JSON_INCLUDE_DIRS}
${NCLUA_INCLUDE_DIRS}
${LUA_INCLUDE_DIR}
${CMAKE_BINARY_DIR} # configured config.h
)
set(LIBGINGA_LIBS
pthread
${GLIB_LIBRARIES}
${GLIB_GIO_LIBRARIES}
${LIBXML2_LIBRARIES}
${GDK3_LIBRARIES}
${GDKPIXBUF_LIBRARIES}
${CAIRO_LIBRARIES}
${FONTCONFIG_LIBRARIES}
${PANGO_LIBRARIES}
${RSVG_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GSTREAMER_APP_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${LIBSOUP_LIBRARIES}
${GSSDP_LIBRARIES}
${JSON_LIBRARIES}
${NCLUA_LIBRARIES}
${LUA_LIBRARIES}
)
# libginga target
add_library(libginga ${LIBGINGA_SOURCES})
if(WITH_NCLUA_BUILD)
add_dependencies(libginga nclua_build)
endif()
target_include_directories(libginga PRIVATE ${LIBGINGA_INCLUDE_DIRS})
target_link_libraries(libginga PRIVATE ${LIBGINGA_LIBS})
set_target_properties(libginga PROPERTIES OUTPUT_NAME "ginga")
# ginga cli target
add_executable(ginga src/ginga.cpp)
target_include_directories(ginga PRIVATE ${LIBGINGA_INCLUDE_DIRS})
target_include_directories(ginga PRIVATE ${GINGAGUI_GTK_INCLUDE_DIRS})
target_link_libraries(ginga PRIVATE libginga ${GTK3_LIBRARIES})
# gingagui target
set(GINGAGUI_GTK_SOURCES
./src/gingagui/gingagui.cpp
./src/gingagui/SaveLoadSettings.cpp
./src/gingagui/AboutWindow.cpp
./src/gingagui/BigPictureWindow.cpp
./src/gingagui/Draw.cpp
./src/gingagui/FullscreenWindow.cpp
./src/gingagui/HelpWindow.cpp
./src/gingagui/MainWindow.cpp
./src/gingagui/TvControlWindow.cpp
)
set(GINGAGUI_GTK_INCLUDE_DIRS
./src/gingagui/
${LIBGINGA_INCLUDE_DIRS}
${GTK3_INCLUDE_DIRS}
)
set(GINGAGUI_GTK_LIBS
${LIBGINGA_LIBS}
${GTK3_LIBRARIES}
)
add_executable(gingagui ${GINGAGUI_GTK_SOURCES})
target_include_directories(gingagui PRIVATE ${GINGAGUI_GTK_INCLUDE_DIRS})
target_link_libraries(gingagui PRIVATE libginga ${GINGAGUI_GTK_LIBS})
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_BUILD_TYPE STREQUAL "Release")
# prevent open console
# https://stackoverflow.com/questions/2281514/how-to-hide-command-prompt-for-my-windows-gtk-apps
# https://github.com/baktragh/mmSAP/commit/f97531512e3c33fe71fd4eec36a4cb42f22bae90
target_link_libraries(gingagui PRIVATE "-mwindows" )
endif()
# ------------------------
# tests
# ------------------------
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
macro(add_ginga_test target)
add_executable(${target} EXCLUDE_FROM_ALL ${ARGN})
target_include_directories(${target} PRIVATE ${GINGAGUI_GTK_INCLUDE_DIRS})
target_link_libraries(${target} PRIVATE libginga ${GINGAGUI_GTK_LIBS})
add_dependencies(${target} libginga)
add_dependencies(check ${target})
add_test(${target} ${CMAKE_BINARY_DIR}/${target})
if(${target} MATCHES xfail-*)
set_tests_properties(${target} PROPERTIES WILL_FAIL TRUE)
endif()
endmacro()
file(GLOB GINGA_TESTS_SRC "./tests/*.cpp")
foreach(SRC ${GINGA_TESTS_SRC})
get_filename_component(TEST_NAME ${SRC} NAME_WE)
add_ginga_test(${TEST_NAME} ${SRC})
# fix PATH when using not-msys testing tool (vscode cmake-test-explorer)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "PATH=%PATH%\;C:\\msys64\\mingw64\\bin")
endif()
endforeach()
# ------------------------
# install
# ------------------------
set(ICON "${CMAKE_SOURCE_DIR}/src/gingagui/icons/common/ginga.ico")
# <install_prefix> should differ Linux and Windows
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_INSTALL_PREFIX "/usr/")
install(TARGETS libginga DESTINATION lib)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
install(TARGETS libginga DESTINATION bin)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/deploy)
endif()
# install files src
install(TARGETS ginga DESTINATION bin)
install(TARGETS gingagui DESTINATION bin)
install(DIRECTORY src/gingagui/icons/ DESTINATION share/ginga/icons)
install(FILES src/gingagui/ncl-apps.xml DESTINATION share/ginga/)
install(FILES src/gingagui/style/dark.css src/gingagui/style/light.css DESTINATION share/ginga/style)
install(FILES ${ICON} DESTINATION share/pixmaps)
set(GINGADATADIR ${CMAKE_INSTALL_PREFIX}/share/ginga/)
set(GINGABINDIR ${CMAKE_INSTALL_PREFIX}/bin)
# others required install at Windows
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows requires the following extra steps:
# * <install_prefix>/bin/gingagui.exe requires:
install(DIRECTORY "C:/msys64/mingw64/share/icons/hicolor/16x16/" DESTINATION share/icons/hicolor/16x16)
install(DIRECTORY "C:/msys64/mingw64/share/icons/Adwaita/16x16/" DESTINATION share/icons/Adwaita/16x16)
install(DIRECTORY "C:/msys64/mingw64/share/icons/Adwaita/scalable/ui/" DESTINATION share/icons/Adwaita/16x16/actions)
# * <install_prefix>/bin/libnclua-0.dll requires:
install(DIRECTORY "C:/msys64/mingw64/share/lua/5.3/nclua/" DESTINATION share/lua/5.3/nclua)
install(DIRECTORY "C:/msys64/mingw64/lib/lua/5.3/nclua/" DESTINATION lib/lua/5.3/nclua)
# * <install_prefix>/bin/libginga.dll requires:
install(DIRECTORY "C:/msys64/mingw64/lib/gdk-pixbuf-2.0/" DESTINATION lib/gdk-pixbuf-2.0)
# * <install_prefix>/bin/libglib-2.0-0.dll requires:
install(DIRECTORY "C:/msys64/mingw64/share/glib-2.0/" DESTINATION share/glib-2.0)
# * <install_prefix>/bin/libgstreamer-1.0-0.dll
# https://gstreamer.freedesktop.org/documentation/installing/on-windows.html?gi-language=c#download-and-install-gstreamer-binaries
install(DIRECTORY "C:/msys64/mingw64/lib/gstreamer-1.0/" DESTINATION lib/gstreamer-1.0)
# * <install_prefix> is suposed to run outside msys2 bash (from cmd orpowershell), so ginga deps should be packaged.
# The following code use GET_RUNTIME_DEPENDENCIES to get at runtime
# https://discourse.cmake.org/t/file-get-runtime-deps-issues/2574/3
install(CODE [[
LIST(APPEND pre_exclude_regexes "api-ms-.*") # windows API
LIST(APPEND pre_exclude_regexes "ext-ms-.*") # windows API
LIST(APPEND pre_exclude_regexes "ieshims.dll") # windows API
LIST(APPEND pre_exclude_regexes "emclient.dll") # windows API
LIST(APPEND pre_exclude_regexes "devicelockhelpers.dll") # windows API
LIST(APPEND post_exclude_regexes ".*WINDOWS[\\/]system32.*") # windows system dlls
file(GLOB GST_PLUGINS "C:/msys64/mingw64/lib/gstreamer-1.0/*.dll")
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES $<TARGET_FILE:ginga> $<TARGET_FILE:gingagui> "C:/msys64/mingw64/bin/gst-play-1.0.exe"
LIBRARIES ${GST_PLUGINS} $<TARGET_FILE:libginga>
DIRECTORIES "C:/msys64/mingw64/bin/"
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
PRE_EXCLUDE_REGEXES ${pre_exclude_regexes}
POST_EXCLUDE_REGEXES ${post_exclude_regexes}
POST_INCLUDE_REGEXES ${post_include_regexes}
)
# message("-- GET_RUNTIME_DEPENDENCIES LIBRARIES=$<TARGET_FILE:libginga> ${GST_PLUGINS}")
# message("-- GET_RUNTIME_DEPENDENCIES EXECUTABLES=$<TARGET_FILE:ginga> $<TARGET_FILE:gingagui> C:/msys64/mingw64/bin/gst-play-1.0.exe")
# message("-- GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR=${_r_deps}")
# message("-- GET_RUNTIME_DEPENDENCIES UNRESOLVED_DEPENDENCIES_VAR=${_u_deps}")
foreach(_file ${_r_deps})
file(INSTALL
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endforeach()
]])
# * install gst-play-1.0.exe for testing
install(FILES "C:/msys64/mingw64/bin/gst-play-1.0.exe" DESTINATION bin)
endif()
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/build-cmake/config.h.in ${CMAKE_BINARY_DIR}/config.h)
# ------------------------
# cpack
# ------------------------
set(CPACK_PACKAGE_VENDOR "TeleMídia Lab/PUC-Rio")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_CONTACT alan@telemidia.puc-rio.br)
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_NAME "ginga-itv") # ginga already exist in apt
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alan Guedes")
set(CPACK_DEBIAN_PACKAGE_SECTION "contrib/graphics")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${DESCRIPTION})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "liblua5.2-0, libglib2.0-0, libpango-1.0-0, librsvg2-2, libsoup2.4-1, libgstreamer1.0-0, libgstreamer-plugins-base1.0-0, libfontconfig1, libgtk-3-0, gstreamer1.0-plugins-good, gstreamer1.0-plugins-bad, gstreamer1.0-plugins-ugly, gstreamer1.0-libav, libgssdp-1.2-0, libjsoncpp25, nclua")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
set(CPACK_DEBIAN_REPLACES "xz")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CPACK_GENERATOR "NSIS")
set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY ${PACKAGE_DESCRIPTION})
set(CPACK_NSIS_INSTALLED_ICON_NAME ${ICON})
set(CPACK_NSIS_MUI_ICON ${ICON})
set(CPACK_NSIS_MUI_UNIICON ${ICON})
set(CPACK_NSIS_MANIFEST_DPI_AWARE "ON")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_DISPLAY_NAME ${DISPLAY_NAME})
set(CPACK_NSIS_BRANDING_TEXT ${DISPLAY_NAME})
set(CPACK_NSIS_PACKAGE_NAME ${DISPLAY_NAME})
set(CPACK_NSIS_HELP_LINK ${PACKAGE_URL})
set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_URL})
set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
# install location
set(CPACK_NSIS_INSTALL_ROOT "$LOCALAPPDATA\\\\Programs")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${DISPLAY_NAME}) # CPACK_NSIS_INSTALL_ROOT\Ginga
string(APPEND CPACK_NSIS_DEFINES "\nRequestExecutionLevel user") # non-admin install
set(CPACK_NSIS_CREATE_ICONS_EXTRA "
CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Ginga.lnk' '$INSTDIR\\\\bin\\\\gingagui.exe' ' ' '$INSTDIR\\\\share\\\\pixmaps\\\\ginga.ico'
")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "
Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Ginga.lnk'
")
# file association: https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#setting-file-extension-associations-with-nsis
# using HKCU: https://stackoverflow.com/questions/27091647/windows-file-association-using-nsis-script
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCU 'Software\\\\Classes\\\\.ncl' '' 'NCL'
WriteRegStr HKCU 'Software\\\\Classes\\\\NCL' '' 'NCL Document'
WriteRegStr HKCU 'Software\\\\Classes\\\\NCL\\\\DefaultIcon' '' '$INSTDIR\\\\share\\\\pixmaps\\\\ginga.ico'
WriteRegStr HKCU 'Software\\\\Classes\\\\NCL\\\\shell' '' 'open'
WriteRegStr HKCU 'Software\\\\Classes\\\\NCL\\\\shell\\\\open\\\\command' '' '$INSTDIR\\\\bin\\\\gingagui.exe \\\"%1\\\"'
WriteRegStr HKCU 'Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\\\\FileExts\\\\.ncl\\\\OpenWithList' 'a' '$INSTDIR\\\\bin\\\\gingagui.exe'
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
DeleteRegKey HKCU 'Software\\\\Classes\\\\.ncl'
DeleteRegKey HKCU 'Software\\\\Classes\\\\NCL'
")
endif()
include(CPack)
# ------------------------
# message after configure
# ------------------------
message("
---
summary of main build options:
version: ${VERSION}
CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}
CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}
CMAKE_C_COMPILER: ${CMAKE_CXX_COMPILER}
STATIC_LINKING: ${STATIC_LINKING}
BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}
CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}
Optional build:
cef player: ${WITH_CEF}
ginga-qt: ${WITH_GINGAQT}
ginga-gl: ${WITH_OPENGL}
")