1 set(SIMULATOR_INSTALL_PREFIX "" CACHE STRING "Alternative simulator library search path")
3 if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|FreeBSD)")
4 set(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR})
5 set(COMPANION_NAME "companion${C9X_NAME_SUFFIX}")
6 set(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}")
7 if (NOT ${SIMULATOR_INSTALL_PREFIX} STREQUAL "")
8 set(SIMULATOR_LIB_PATH ${SIMULATOR_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
10 set(SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
12 message(STATUS "Simulators library search path: " ${SIMULATOR_LIB_PATH})
13 set(SIMULATOR_LIB_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
15 set(COMPANION_NAME "companion")
16 set(SIMULATOR_NAME "simulator")
19 # This the name that the user will see in the generated DMG and what the application
20 # will be called under /Applications. We include the version string to make installing
21 # different versions for different eeproms easier, i.e. without manually renaming
22 set(COMPANION_OSX_APP_BUNDLE_NAME "OpenTX Companion ${VERSION_MAJOR}.${VERSION_MINOR}")
24 # On OS X we copy dfu-util to the application bundle. This the path from which we copy
25 # the binary (default homebrew path)
26 set(DFU_UTIL_PATH "/usr/local/bin/dfu-util")
27 set(AVRDUDE_PATH "/usr/local/bin/avrdude")
29 option(ALLOW_NIGHTLY_BUILDS "Allow nightly builds download / update") # Disabled by default
30 if(ALLOW_NIGHTLY_BUILDS)
31 add_definitions(-DALLOW_NIGHTLY_BUILDS)
32 endif(ALLOW_NIGHTLY_BUILDS)
34 option(DEBUG_STORAGE_IMPORT "Turn on debug output for storage import") # Disabled by default
35 if(DEBUG_STORAGE_IMPORT)
36 add_definitions(-DDEBUG_STORAGE_IMPORT)
37 message(STATUS "Storage import debugging enabled")
40 add_definitions(-DDEBUG)
43 option(TABLE_LAYOUT "Use QTableWidget for grid layouts") # Disabled by default
45 add_definitions(-DTABLE_LAYOUT)
46 message(STATUS "Using QTableWidget")
50 option(WIN_DO_FULL_INSTALL "'install' target will perform a full installation into CMAKE_INSTALL_PREFIX path, otherwise only supporting DLLs are copied to binaries folder (default)" OFF)
51 option(WIN_USE_CONSOLE "Open a Windows command console for Simulator debug output." OFF)
53 add_definitions(-DWIN_USE_CONSOLE_STDIO)
58 include_directories(${SDL_INCLUDE_DIR})
59 add_definitions(-DJOYSTICKS)
62 add_definitions(${APP_COMMON_DEFINES}) # set in top-level CMakeLists
65 set(WARNING_FLAGS "${WARNING_FLAGS} -Wall")
66 if(WARNINGS_AS_ERRORS)
67 set(WARNING_FLAGS "${WARNING_FLAGS} -Werror")
70 # silence lots of warnings regarding "insecure" use of functions (sprintf, strcpy, etc)
71 set(WARNING_FLAGS "${WARNING_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
72 if(WARNINGS_AS_ERRORS)
73 set(WARNING_FLAGS "${WARNING_FLAGS} /WX")
78 include_directories(SYSTEM ${WIN_INCLUDE_DIRS})
79 if(NOT WIN_USE_CONSOLE)
80 set(WIN_EXECUTABLE_TYPE WIN32) # GUI (WinMain) app
83 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /LD /MP")
84 if(NOT WIN_USE_CONSOLE)
85 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01") # is this even needed?
88 # struct packing breaks on MinGW w/out -mno-ms-bitfields: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 & http://stackoverflow.com/questions/24015852/struct-packing-and-alignment-with-mingw
89 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields")
92 set(PTHREAD_LIBRARY pthread)
93 link_directories(/usr/local/lib)
96 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
98 use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
102 ${CMAKE_CURRENT_BINARY_DIR}
104 ${COMPANION_SRC_DIRECTORY}
105 ${COMPANION_SRC_DIRECTORY}/shared
106 ${SIMU_SRC_DIRECTORY}
107 ${COMPANION_SRC_DIRECTORY}/thirdparty/qcustomplot
108 ${COMPANION_SRC_DIRECTORY}/thirdparty/miniz
109 ${COMPANION_SRC_DIRECTORY}/storage
112 ############# Do macro replacements on input files #############
113 configure_file(${COMPANION_SRC_DIRECTORY}/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
114 configure_file(${COMPANION_SRC_DIRECTORY}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY)
115 configure_file(${COMPANION_SRC_DIRECTORY}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY)
117 ############# Translations ###############
119 ### Generate .qm files and assemble resource (qrc) file.
121 # available Companion translations (src/translations/*.ts)
122 set(LANGUAGES cs de en es fi fr it pl sv zh_CN)
123 foreach(language ${LANGUAGES})
124 list(APPEND companion_TS translations/companion_${language}.ts)
127 qt5_add_translation(companion_QM ${companion_TS})
129 # add Qt translations if found
130 if(QT_TRANSLATIONS_DIR)
131 # Some languages have all translations in one qt_*.qm file and others break them up into modules, in which case we need qt_base_*.qm
132 file(GLOB qtbase_QM "${QT_TRANSLATIONS_DIR}/qtbase_*.qm")
133 file(GLOB qt_QM "${QT_TRANSLATIONS_DIR}/qt_??.qm") # don't want to match "qt_help_*.qm"
134 list(APPEND qt_QM "${QT_TRANSLATIONS_DIR}/qt_zh_CN.qm" "${QT_TRANSLATIONS_DIR}/qt_zh_TW.qm") # exceptions not matched by the GLOB
136 message(STATUS "QT_TRANSLATIONS_DIR not found, unable to package pre-built Qt translations with application.")
139 set(TRANSLATIONS_QRC "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc")
141 # Dynamically create translations.qrc file (XML) from all collected translation files.
142 foreach(qm_file ${companion_QM} ${qt_QM} ${qtbase_QM})
143 get_filename_component(qm_file_name ${qm_file} NAME)
144 # Add file with full path and file name (w/out path) as alias to be used in actual code
145 set(TRANSLATION_FILES_LIST "${TRANSLATION_FILES_LIST} <file alias=\"${qm_file_name}\">${qm_file}</file>\n")
147 configure_file(${COMPANION_SRC_DIRECTORY}/translations.qrc.in ${TRANSLATIONS_QRC} @ONLY)
149 ### Add optional "translations" target for updating .ts files
150 if(QT_LUPDATE_EXECUTABLE)
151 add_custom_target(translations
152 WORKING_DIRECTORY ${COMPANION_SRC_DIRECTORY}
153 COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts ${companion_TS}
156 message(STATUS "Qt lupdate not found, 'translations' target will not be availabe.")
159 ############# Common lib ###############
162 appdebugmessagehandler.cpp
169 firmwares/er9x/er9xeeprom.cpp
170 firmwares/er9x/er9xinterface.cpp
171 firmwares/ersky9x/ersky9xeeprom.cpp
172 firmwares/ersky9x/ersky9xinterface.cpp
173 firmwares/opentx/opentxeeprom.cpp
174 firmwares/opentx/opentxinterface.cpp
175 modeledit/node.cpp # used in simulator
176 modeledit/edge.cpp # used by node
180 appdebugmessagehandler.h
190 qt5_wrap_cpp(common_SRCS ${common_MOC_HDRS})
191 qt5_add_resources(common_RCC ${common_RESOURCES})
192 #add_custom_target(gen_qrc DEPENDS ${common_RCC} ${companion_QM})
194 add_library(common ${common_SRCS} ${common_RCC})
195 qt5_use_modules(common Core Xml Widgets)
196 target_link_libraries(common PRIVATE simulation)
197 #add_dependencies(common gen_qrc)
199 set(CPN_COMMON_LIB common)
201 ############# Supporting libraries ###############
203 add_subdirectory(shared)
204 add_subdirectory(modeledit)
205 add_subdirectory(generaledit)
206 add_subdirectory(simulation)
207 add_subdirectory(storage)
208 add_subdirectory(thirdparty/qcustomplot)
210 ############# Companion ###############
216 apppreferencesdialog.cpp
217 fwpreferencesdialog.cpp
219 multimodelprinter.cpp
222 releasenotesdialog.cpp
223 releasenotesfirmwaredialog.cpp
224 customizesplashdialog.cpp
231 flashfirmwaredialog.cpp
232 flasheepromdialog.cpp
238 splashlibrarydialog.cpp
247 set(companion_MOC_HDRS
248 apppreferencesdialog.h
249 fwpreferencesdialog.h
257 releasenotesfirmwaredialog.h
258 customizesplashdialog.h
259 splashlibrarydialog.h
266 flashfirmwaredialog.h
283 apppreferencesdialog.ui
284 fwpreferencesdialog.ui
289 customizesplashdialog.ui
290 splashlibrarydialog.ui
293 flashfirmwaredialog.ui
302 qt5_wrap_ui(companion_SRCS ${companion_UIS})
303 qt5_wrap_cpp(companion_SRCS ${companion_MOC_HDRS})
305 add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${icon_RC})
306 qt5_use_modules(${COMPANION_NAME} Core Widgets Network)
307 target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit simulation ${CPN_COMMON_LIB} qcustomplot shared storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
309 PrintTargetReport("${COMPANION_NAME}")
311 ############# Standalone simulator ###############
313 set(simu_SRCS simulator.cpp )
315 add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS} ${icon_RC})
316 target_link_libraries(${SIMULATOR_NAME} PRIVATE simulation ${CPN_COMMON_LIB} storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
318 ############# Install ####################
320 # Generate list of simulator plugins, used by all platforms
321 file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/*opentx-*simulator${CMAKE_SHARED_LIBRARY_SUFFIX}")
322 # the current flavour is not automatically added if build in the current cmake iteration, so always
323 # add its library name to be sure
324 string(TOLOWER ${PCB} FLAVOUR)
326 cmake_policy(SET CMP0026 OLD) # https://cmake.org/cmake/help/v3.0/policy/CMP0026.html
328 get_property(current_plugin TARGET opentx-${FLAVOUR}-simulator PROPERTY LOCATION)
329 list(APPEND simulator_plugins "${current_plugin}")
331 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
333 message(STATUS "install " ${CMAKE_BINARY_DIR} " to " ${CMAKE_INSTALL_PREFIX}/bin)
334 install(TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
335 install(TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
336 install(FILES ${simulator_plugins} DESTINATION "${SIMULATOR_LIB_INSTALL_PATH}")
337 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop)
338 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop)
339 if(${CMAKE_INSTALL_PREFIX} MATCHES "/usr/local")
340 set(INSTALL_TEMP_SHR_PFX "/usr/")
341 set(INSTALL_TEMP_LIB_PFX "/")
343 install(FILES images/linuxicons/16x16/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png)
344 install(FILES images/linuxicons/22x22/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png)
345 install(FILES images/linuxicons/24x24/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png)
346 install(FILES images/linuxicons/32x32/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png)
347 install(FILES images/linuxicons/48x48/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png)
348 install(FILES images/linuxicons/128x128/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png)
349 install(FILES images/linuxicons/256x256/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png)
350 install(FILES images/linuxicons/512x512/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png)
351 install(FILES images/linuxicons/scalable/companion.svg DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg)
352 install(FILES ../targets/linux/45-companion-taranis.rules DESTINATION ${INSTALL_TEMP_LIB_PFX}lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-taranis.rules)
353 # Linux specific code
354 set(OperatingSystem "Linux")
358 set(QT_DLL_DIR ${QT_LIB_DIR})
359 set(INSTALL_TEMP_QTDLL_FILES Qt5Core Qt5Gui Qt5Widgets Qt5Xml Qt5Network Qt5PrintSupport Qt5Multimedia Qt5Svg)
360 set(INSTALL_TEMP_ICUDLL_FILES icudt54.dll icuin54.dll icuuc54.dll)
361 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
362 set(INSTALL_TEMP_QTDLL_SFX "d")
365 if(NOT WIN_DO_FULL_INSTALL)
366 # Just copy supporting DLLs to build folder
367 set(INSTALL_DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
368 message(STATUS "Partial install to " ${INSTALL_DESTINATION})
370 # Full Windows installation with all supporting files
371 set(INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}")
372 message(STATUS "Full install to " ${INSTALL_DESTINATION})
373 # companion & simulator binaries
374 install(TARGETS ${COMPANION_NAME} DESTINATION ${INSTALL_DESTINATION})
375 install(TARGETS ${SIMULATOR_NAME} DESTINATION ${INSTALL_DESTINATION})
376 install(FILES ${simulator_plugins} DESTINATION "${INSTALL_DESTINATION}")
377 # supporting utilities
378 set(INSTALL_TEMP_FILES avrdude.exe avrdude.conf dfu-util.exe libusb0.dll libusb-1.0.dll)
379 foreach(tmpfile ${INSTALL_TEMP_FILES})
380 install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/${tmpfile}" DESTINATION ${INSTALL_DESTINATION})
382 endif() # WIN_DO_FULL_INSTALL
385 foreach(tmpfile ${INSTALL_TEMP_QTDLL_FILES})
386 install(FILES ${QT_DLL_DIR}/${tmpfile}${INSTALL_TEMP_QTDLL_SFX}.dll DESTINATION ${INSTALL_DESTINATION})
388 install(FILES ${QT_DLL_DIR}/../plugins/platforms/qwindows${INSTALL_TEMP_QTDLL_SFX}.dll DESTINATION ${INSTALL_DESTINATION}/platforms)
390 foreach(tmpfile ${INSTALL_TEMP_ICUDLL_FILES})
391 # Qt5.7+ doesn't use icu dlls anymore, hence optional
392 install(FILES ${QT_DLL_DIR}/${tmpfile}.dll DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
395 if(SDL_FOUND AND SDL_LIBRARY_PATH AND EXISTS "${SDL_LIBRARY_PATH}/SDL.dll")
396 set(SDL_DIR ${SDL_LIBRARY_PATH}) # this is also used by NSIS installer script
397 install(FILES ${SDL_DIR}/SDL.dll DESTINATION ${INSTALL_DESTINATION})
399 message(WARNING "Installer: SDL.dll not found!")
401 # C++/system dlls, depends on compiler
403 string(REPLACE "\\" "/" WIN_SYSDIR "$ENV{windir}")
404 set(WIN_SYSDIR "${WIN_SYSDIR}/SysWOW64") # This would be "system32" for a 64-bit build or on x86... but how to tell?
405 if(IS_DIRECTORY "${WIN_SYSDIR}")
406 install(FILES "${WIN_SYSDIR}/msvcp140.dll" "${WIN_SYSDIR}/vcruntime140.dll" DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
409 install(FILES "${WIN_PTHREAD_DLL}" DESTINATION ${INSTALL_DESTINATION})
412 get_filename_component(MINGW_DIR ${CMAKE_CXX_COMPILER} PATH)
413 if(IS_DIRECTORY ${MINGW_DIR})
414 install(FILES "${MINGW_DIR}/libgcc_s_dw2-1.dll" "${MINGW_DIR}/libstdc++-6.dll" "${MINGW_DIR}/libwinpthread-1.dll" DESTINATION ${INSTALL_DESTINATION})
415 set(MINGW_DIR "${MINGW_DIR}/../opt/bin")
417 install(FILES "${MINGW_DIR}/libeay32.dll" "${MINGW_DIR}/ssleay32.dll" DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
421 endif() # WIN32 install
423 ############# Packaging ####################
425 # Create Windows installer with NSIS (only works for MSVC for now)
428 set(COMPANION_NSI_IN_FILE companion-vs.nsi.in)
429 set(SIMULATOR_NSI_IN_FILE simulator-vs.nsi.in)
431 set(COMPANION_NSI_IN_FILE companion-msys.nsi.in)
432 set(SIMULATOR_NSI_IN_FILE simulator-msys.nsi.in)
435 set(SYSDIR "$ENV{windir}/system32")
436 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${COMPANION_NSI_IN_FILE} ${PROJECT_BINARY_DIR}/companion/companion.nsi @ONLY)
437 #configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${SIMULATOR_NSI_IN_FILE} ${PROJECT_BINARY_DIR}/companion/simulator.nsi @ONLY)
439 find_program(NSIS_EXE makensis.exe PATHS
440 "C:/Program Files/NSIS"
441 "C:/Program Files (x86)/NSIS"
445 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/companion/companion-windows.exe
446 COMMAND "${NSIS_EXE}" ARGS ${PROJECT_BINARY_DIR}/companion/companion.nsi
447 DEPENDS companion simulator opentx-simulators ${PROJECT_BINARY_DIR}/companion/companion.nsi
448 COMMENT "Companion Windows NSIS Installer")
450 # add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/companion/simulator-install.exe
451 # COMMAND "${NSIS_EXE}" ARGS ${PROJECT_BINARY_DIR}/companion/simulator.nsi
452 # DEPENDS simulator ${PROJECT_BINARY_DIR}/companion/simulator.nsi
453 # COMMENT "Simulator Windows NSIS Installer")
455 add_custom_target(installer
456 DEPENDS ${PROJECT_BINARY_DIR}/companion/companion-windows.exe
457 # DEPENDS ${PROJECT_BINARY_DIR}/companion/simulator-windows.exe
458 SOURCES ${PROJECT_BINARY_DIR}/companion/companion.nsi
459 # SOURCES ${PROJECT_BINARY_DIR}/companion/simulator.nsi
463 set(CPACK_PACKAGE_NAME "companion${C9X_NAME_SUFFIX}")
464 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Models and settings editor for the OpenTX open source firmware")
465 string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
467 # The file stripping is deliberately disabled, with the stripped file we get
468 # very poor trace-backs from the users when they report Companion crash
469 set(CPACK_STRIP_FILES FALSE)
471 # Qt5 + Cmake + Mac is poorly documented. A lot of this is guesswork
472 # and trial and error. Do not hesitate to fix it for the better
474 set(plugin_dest_dir ${COMPANION_NAME}.app/Contents/Plugins)
475 set(qtconf_dest_dir ${COMPANION_NAME}.app/Contents/Resources)
476 set(APPS "\${CMAKE_INSTALL_PREFIX}/${COMPANION_NAME}.app")
477 set(companion_res_dir ${COMPANION_NAME}.app/Contents/Resources)
479 set_target_properties(${COMPANION_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Companion ${VERSION_MAJOR}.${VERSION_MINOR}")
480 set_target_properties(${SIMULATOR_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simulator ${VERSION_MAJOR}.${VERSION_MINOR}")
482 # Use a non standard Info.plist that adds Retina support flags
483 set_target_properties(${COMPANION_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
484 set_target_properties(${SIMULATOR_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
486 INSTALL(TARGETS ${COMPANION_NAME}
487 BUNDLE DESTINATION . COMPONENT Runtime
488 RUNTIME DESTINATION bin COMPONENT Runtime
491 install(FILES ${simulator_plugins} DESTINATION "${companion_res_dir}" COMPONENT Runtime)
493 # Write qt.conf to tell qt where to find it plugins
494 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
495 "[Paths]\nPlugins = Plugins\n")
496 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
497 DESTINATION "${companion_res_dir}"
501 install(DIRECTORY ${PROJECT_SOURCE_DIR}/companion/targets/mac/qt_menu.nib DESTINATION "${companion_res_dir}" COMPONENT Runtime)
503 # manually add the required plugins
504 foreach (plugin ${Qt5Multimedia_PLUGINS} ${Qt5PrintSupport_PLUGINS} ${Qt5Gui_PLUGINS} ${Qt5Svg_PLUGINS})
505 get_target_property(QPA_PLUGIN ${plugin} LOCATION)
506 get_filename_component(QPA_PLUGIN_FILENAME ${QPA_PLUGIN} NAME)
507 # Todo is there a nicer way to get the QT Plugin directory name?!
508 get_filename_component(QPA_PLUGIN_DIRECTORY ${QPA_PLUGIN} DIRECTORY)
509 get_filename_component(QPA_PLUGIN_DIRECTORY ${QPA_PLUGIN_DIRECTORY} NAME)
511 install(FILES ${QPA_PLUGIN} DESTINATION "${plugin_dest_dir}/${QPA_PLUGIN_DIRECTORY}/" COMPONENT Runtime)
513 list(APPEND bundle_qt_libs "\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/${QPA_PLUGIN_DIRECTORY}/${QPA_PLUGIN_FILENAME}")
517 set(MACOSX_BUNDLE_ICON_FILE iconmac.icns)
518 set(MAC_ICON_FILE ${COMPANION_SRC_DIRECTORY}/images/${MACOSX_BUNDLE_ICON_FILE})
519 SET_SOURCE_FILES_PROPERTIES(${MAC_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
520 set(${COMPANION_SOURCES} ${COMPANION_SOURCES} ${PROJECT_SOURCE_DIR}/images/${MACOSX_BUNDLE_ICON_FILE})
521 install(FILES ${MAC_ICON_FILE} DESTINATION ${companion_res_dir} COMPONENT Runtime)
523 # Copy dfu-util and avrdude, resolve symlink first
524 get_filename_component(DFU_UTIL_ABSOLUTE_PATH ${DFU_UTIL_PATH} REALPATH)
525 get_filename_component(AVRDUDE_ABSOLUTE_PATH ${AVRDUDE_PATH} REALPATH)
526 install(PROGRAMS ${DFU_UTIL_ABSOLUTE_PATH} ${AVRDUDE_ABSOLUTE_PATH} DESTINATION ${companion_res_dir} COMPONENT Runtime)
527 set(bundle_tools_path "\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/dfu-util;\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/avrdude")
529 # Include depencies (adding frameworks, fixing the embbeded libraries)
530 # I get write errors without setting BU_CHMOD_BUNDLE_ITEMS even though it is
531 # technically a hack (that is already is in the Bundle library ...)
533 include(BundleUtilities)
534 file(GLOB bundle_simulator_libs \"\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/libopentx-*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
535 set(BU_CHMOD_BUNDLE_ITEMS on)
536 fixup_bundle(\"${APPS}\" \"\${bundle_simulator_libs};${bundle_qt_libs};${bundle_tools_path}\" \"${QT_LIB_DIR}\")
537 file(RENAME \"\${CMAKE_INSTALL_PREFIX}/${COMPANION_NAME}.app\" \"\${CMAKE_INSTALL_PREFIX}/${COMPANION_OSX_APP_BUNDLE_NAME}.app\")
541 find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
544 set(CPACK_GENERATOR "DEB")
546 COMMAND ${DPKG_PROGRAM} --print-architecture
547 OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
548 OUTPUT_STRIP_TRAILING_WHITESPACE
550 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
551 set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bertrand Songis <bsongis-nosp@m-gmail.com>")
552 set(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION})
553 set(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
554 set(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
555 set(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR))
556 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
558 set(CPACK_GENERATOR "DragNDrop")
559 # set(CPACK_GENERATOR "TGZ") # for quick testing
560 set(CPACK_BINARY_DRAGNDROP ON)
561 set(CPACK_DMG_BACKGROUND_IMAGE ${COMPANION_SRC_DIRECTORY}/images/splash22_3_dmg.png)
562 set(CPACK_DMG_VOLUME_NAME "OpenTX Companion")
563 set(CPACK_DMG_DS_STORE ${PROJECT_SOURCE_DIR}/companion/targets/mac/DS_Store)
564 set(CPACK_PACKAGE_FILE_NAME "opentx-${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}")
566 set(CPACK_GENERATOR "RPM")
567 set(CPACK_RPM_PACKAGE_VERSION ${VERSION})
568 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
569 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
570 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib /lib/udev /lib/udev/rules.d")