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")
28 set(AVRDUDE_CONF "/usr/local/etc/avrdude.conf")
30 option(ALLOW_NIGHTLY_BUILDS "Allow nightly builds download / update") # Disabled by default
31 if(ALLOW_NIGHTLY_BUILDS)
32 add_definitions(-DALLOW_NIGHTLY_BUILDS)
33 endif(ALLOW_NIGHTLY_BUILDS)
35 option(DEBUG_STORAGE_IMPORT "Turn on debug output for storage import") # Disabled by default
36 if(DEBUG_STORAGE_IMPORT)
37 add_definitions(-DDEBUG_STORAGE_IMPORT)
38 message(STATUS "Storage import debugging enabled")
41 add_definitions(-DDEBUG)
44 option(TABLE_LAYOUT "Use QTableWidget for grid layouts") # Disabled by default
46 add_definitions(-DTABLE_LAYOUT)
47 message(STATUS "Using QTableWidget")
51 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)
52 option(WIN_USE_CONSOLE "Open a Windows command console for Simulator debug output." OFF)
54 add_definitions(-DWIN_USE_CONSOLE_STDIO)
59 include_directories(${SDL_INCLUDE_DIR})
60 add_definitions(-DJOYSTICKS)
63 add_definitions(${APP_COMMON_DEFINES}) # set in top-level CMakeLists
66 set(WARNING_FLAGS "${WARNING_FLAGS} -Wall")
67 if(WARNINGS_AS_ERRORS)
68 set(WARNING_FLAGS "${WARNING_FLAGS} -Werror")
71 # silence lots of warnings regarding "insecure" use of functions (sprintf, strcpy, etc)
72 set(WARNING_FLAGS "${WARNING_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
73 if(WARNINGS_AS_ERRORS)
74 set(WARNING_FLAGS "${WARNING_FLAGS} /WX")
79 include_directories(SYSTEM ${WIN_INCLUDE_DIRS})
80 if(NOT WIN_USE_CONSOLE)
81 set(WIN_EXECUTABLE_TYPE WIN32) # GUI (WinMain) app
85 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /LD /MP")
87 if(NOT WIN_USE_CONSOLE)
88 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01") # is this even needed?
91 get_filename_component(MINGW_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
92 # 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
93 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields")
96 set(PTHREAD_LIBRARY pthread)
97 link_directories(/usr/local/lib)
100 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
102 use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
106 ${CMAKE_CURRENT_BINARY_DIR}
108 ${COMPANION_SRC_DIRECTORY}
109 ${COMPANION_SRC_DIRECTORY}/shared
110 ${SIMU_SRC_DIRECTORY}
111 ${COMPANION_SRC_DIRECTORY}/thirdparty/qcustomplot
112 ${COMPANION_SRC_DIRECTORY}/thirdparty/miniz
113 ${COMPANION_SRC_DIRECTORY}/storage
116 ############# Do macro replacements on input files #############
117 configure_file(${COMPANION_SRC_DIRECTORY}/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
118 configure_file(${COMPANION_SRC_DIRECTORY}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY)
119 configure_file(${COMPANION_SRC_DIRECTORY}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY)
121 ############# Translations ###############
123 ### Generate .qm files and assemble resource (qrc) file.
125 # available Companion translations (src/translations/*.ts)
126 set(LANGUAGES cs de en es fi fr it pl sv zh_CN ja)
127 foreach(language ${LANGUAGES})
128 list(APPEND companion_TS translations/companion_${language}.ts)
131 qt5_add_translation(companion_QM ${companion_TS})
133 # add Qt translations if found
134 if(QT_TRANSLATIONS_DIR)
135 # 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
136 file(GLOB qtbase_QM "${QT_TRANSLATIONS_DIR}/qtbase_*.qm")
137 file(GLOB qt_QM "${QT_TRANSLATIONS_DIR}/qt_??.qm") # don't want to match "qt_help_*.qm"
138 list(APPEND qt_QM "${QT_TRANSLATIONS_DIR}/qt_zh_CN.qm" "${QT_TRANSLATIONS_DIR}/qt_zh_TW.qm") # exceptions not matched by the GLOB
140 message(STATUS "QT_TRANSLATIONS_DIR not found, unable to package pre-built Qt translations with application.")
143 set(TRANSLATIONS_QRC "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc")
145 # Dynamically create translations.qrc file (XML) from all collected translation files.
146 foreach(qm_file ${companion_QM} ${qt_QM} ${qtbase_QM})
147 get_filename_component(qm_file_name ${qm_file} NAME)
148 # Add file with full path and file name (w/out path) as alias to be used in actual code
149 set(TRANSLATION_FILES_LIST "${TRANSLATION_FILES_LIST} <file alias=\"${qm_file_name}\">${qm_file}</file>\n")
151 configure_file(${COMPANION_SRC_DIRECTORY}/translations.qrc.in ${TRANSLATIONS_QRC} @ONLY)
153 ### Add optional "translations" target for updating .ts files
154 if(QT_LUPDATE_EXECUTABLE)
155 add_custom_target(translations
156 WORKING_DIRECTORY ${COMPANION_SRC_DIRECTORY}
157 COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts ${companion_TS}
160 message(STATUS "Qt lupdate not found, 'translations' target will not be availabe.")
163 ############# Common lib ###############
166 appdebugmessagehandler.cpp
170 modeledit/node.cpp # used in simulator
171 modeledit/edge.cpp # used by node
175 appdebugmessagehandler.h
185 qt5_wrap_cpp(common_SRCS ${common_MOC_HDRS})
186 qt5_add_resources(common_RCC ${common_RESOURCES})
188 add_library(common ${common_SRCS} ${common_RCC})
190 target_link_libraries(common
200 ${WIN_LINK_LIBRARIES}
203 set(CPN_COMMON_LIB common)
205 ############# Supporting libraries ###############
207 add_subdirectory(datamodels)
208 add_subdirectory(firmwares)
209 add_subdirectory(shared)
210 add_subdirectory(modeledit)
211 add_subdirectory(generaledit)
212 add_subdirectory(simulation)
213 add_subdirectory(storage)
214 add_subdirectory(thirdparty/qcustomplot)
215 add_subdirectory(thirdparty/maxlibqt/src/widgets)
217 ############# Companion ###############
223 apppreferencesdialog.cpp
224 fwpreferencesdialog.cpp
226 multimodelprinter.cpp
229 releasenotesdialog.cpp
230 releasenotesfirmwaredialog.cpp
231 customizesplashdialog.cpp
238 flashfirmwaredialog.cpp
239 flasheepromdialog.cpp
245 splashlibrarydialog.cpp
252 dialogs/filesyncdialog.cpp # TODO move to own lib with other dialogs
255 set(companion_MOC_HDRS
256 apppreferencesdialog.h
257 fwpreferencesdialog.h
265 releasenotesfirmwaredialog.h
266 customizesplashdialog.h
267 splashlibrarydialog.h
274 flashfirmwaredialog.h
286 dialogs/filesyncdialog.h
294 apppreferencesdialog.ui
295 fwpreferencesdialog.ui
300 customizesplashdialog.ui
301 splashlibrarydialog.ui
304 flashfirmwaredialog.ui
311 set(icon_RC images/winicons/icon.rc)
314 qt5_wrap_ui(companion_SRCS ${companion_UIS})
315 qt5_wrap_cpp(companion_SRCS ${companion_MOC_HDRS})
317 add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${icon_RC})
318 target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit qcustomplot shared ${CPN_COMMON_LIB})
320 PrintTargetReport("${COMPANION_NAME}")
322 ############# Standalone simulator ###############
324 set(simu_SRCS simulator.cpp )
326 add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS} ${icon_RC})
327 target_link_libraries(${SIMULATOR_NAME} PRIVATE ${CPN_COMMON_LIB})
330 add_subdirectory(tests)
333 ############# Install ####################
335 # Generate list of simulator plugins, used by all platforms
337 file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/Release/*opentx-*simulator${CMAKE_SHARED_LIBRARY_SUFFIX}")
339 file(GLOB simulator_plugins "${CMAKE_BINARY_DIR}/*opentx-*simulator${CMAKE_SHARED_LIBRARY_SUFFIX}")
342 # the current flavour is not automatically added if build in the current cmake iteration, so always
343 # add its library name to be sure
344 if(PCB STREQUAL X7 AND PCBREV STREQUAL T12)
346 elseif(PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019)
347 set(FLAVOUR x9d+2019)
348 elseif(PCB STREQUAL X10 AND PCBREV STREQUAL EXPRESS)
349 set(FLAVOUR x10express)
350 elseif(PCB STREQUAL X10 AND PCBREV STREQUAL T16)
353 string(TOLOWER ${PCB} FLAVOUR)
356 cmake_policy(SET CMP0026 OLD) # https://cmake.org/cmake/help/v3.0/policy/CMP0026.html
360 get_property(current_plugin TARGET opentx-${FLAVOUR}-simulator PROPERTY LOCATION)
361 list(APPEND simulator_plugins "${current_plugin}")
364 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
365 message(STATUS "install " ${CMAKE_BINARY_DIR} " to " ${CMAKE_INSTALL_PREFIX}/bin)
366 install(TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
367 install(TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
368 install(FILES ${simulator_plugins} DESTINATION "${SIMULATOR_LIB_INSTALL_PATH}")
369 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop)
370 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop)
371 if(${CMAKE_INSTALL_PREFIX} MATCHES "/usr/local")
372 set(INSTALL_TEMP_SHR_PFX "/usr/")
373 set(INSTALL_TEMP_LIB_PFX "/")
375 install(FILES images/linuxicons/16x16/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png)
376 install(FILES images/linuxicons/22x22/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png)
377 install(FILES images/linuxicons/24x24/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png)
378 install(FILES images/linuxicons/32x32/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png)
379 install(FILES images/linuxicons/48x48/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png)
380 install(FILES images/linuxicons/128x128/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png)
381 install(FILES images/linuxicons/256x256/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png)
382 install(FILES images/linuxicons/512x512/companion.png DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png)
383 install(FILES images/linuxicons/scalable/companion.svg DESTINATION ${INSTALL_TEMP_SHR_PFX}share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg)
384 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)
385 install(FILES ../targets/linux/45-usbasp.rules DESTINATION ${INSTALL_TEMP_LIB_PFX}lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-usbasp.rules)
386 # Linux specific code
387 set(OperatingSystem "Linux")
390 if(NOT WIN_DO_FULL_INSTALL)
391 # Just copy supporting DLLs to build folder
392 set(INSTALL_DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
393 message(STATUS "Partial install to " ${INSTALL_DESTINATION})
395 # Full Windows installation with all supporting files
396 set(INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}")
397 message(STATUS "Full install to " ${INSTALL_DESTINATION})
398 # companion & simulator binaries
399 install(TARGETS ${COMPANION_NAME} DESTINATION ${INSTALL_DESTINATION})
400 install(TARGETS ${SIMULATOR_NAME} DESTINATION ${INSTALL_DESTINATION})
401 install(FILES ${simulator_plugins} DESTINATION "${INSTALL_DESTINATION}")
402 # supporting utilities
403 set(INSTALL_TEMP_FILES avrdude.exe avrdude.conf dfu-util.exe libusb0.dll libusb-1.0.dll license.txt)
404 foreach(tmpfile ${INSTALL_TEMP_FILES})
405 install(FILES "${COMPANION_SRC_DIRECTORY}/../targets/windows/${tmpfile}" DESTINATION ${INSTALL_DESTINATION})
407 endif() # WIN_DO_FULL_INSTALL
409 # Qt dlls (using windeployqt)
410 ## Qt translations are already packaged into our custom qrc. Also don't need software rendering engines.
411 set(wdqtopts --no-translations --no-opengl-sw --no-system-d3d-compiler --no-angle)
412 if(CMAKE_BUILD_TYPE STREQUAL "Release")
413 set(wdqtopts ${wdqtopts} --release) # release builds aren't always properly detected with mingw
416 set(wdqtopts ${wdqtopts} --no-compiler-runtime) # --compiler-runtime includes vcredist_x86, but we just copy the required DLLs manually
418 set(wdqtopts ${wdqtopts} -dir "\"${INSTALL_DESTINATION}\"" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/${COMPANION_NAME}.exe" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/${SIMULATOR_NAME}.exe")
420 # Add installer command to execute windeployqt
421 message(STATUS "windeployqt command: ${QT_BIN_DIR}/windeployqt.exe ${wdqtopts}")
422 install(CODE "execute_process(COMMAND \"${QT_BIN_DIR}/windeployqt.exe\" ${wdqtopts})")
425 if(SDL_FOUND AND EXISTS "${SDL_LIBRARY_PATH}/SDL.dll")
426 set(SDL_DIR ${SDL_LIBRARY_PATH}) # this is also used by NSIS installer script
427 install(FILES ${SDL_DIR}/SDL.dll DESTINATION ${INSTALL_DESTINATION})
429 message(WARNING "Installer: SDL.dll not found, set SDL_LIBRARY_PATH manually.")
432 # libeay (SSL) dlls (used by QtNetwork) -- not strictly required but avoids possible issues with downloads and Qt warnings.
433 file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" WIN_PROGRAM_FILES)
434 find_path(EAY_LIB_DIR libeay32.dll HINTS
435 "${WIN_PROGRAM_FILES}/OpenSSL" "${WIN_PROGRAM_FILES}/OpenSSL-Win32"
436 "C:/OpenSSL/" "C:/OpenSSL-Win32/"
437 "${WIN_EXTRA_LIBS_PATH}" "${WIN_EXTRA_LIBS_PATH}/OpenSSL" "${WIN_EXTRA_LIBS_PATH}/OpenSSL-Win32"
438 "${MINGW_DIR}/../opt/bin"
439 "${PYTHON_DIRECTORY}/lib/site-packages/PyQt4"
441 DOC "Path to libeay32.dll and ssleay32.dll (OpenSSL)"
444 install(FILES "${EAY_LIB_DIR}/libeay32.dll" "${EAY_LIB_DIR}/ssleay32.dll" DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
446 message(WARNING "Installer: SSL libs not found, set EAY_LIB_DIR manually.")
449 # C++/system dlls, depends on compiler
451 file(TO_CMAKE_PATH "$ENV{windir}/SysWOW64" WIN_SYSDIR) # This would be "system32" for a 64-bit build or on x86... but how to tell?
452 if (NOT EXISTS "${WIN_SYSDIR}")
453 file(TO_CMAKE_PATH "$ENV{windir}/system32" WIN_SYSDIR) # Must be 32-bit Windows.
455 install(FILES "${WIN_SYSDIR}/msvcp140.dll" "${WIN_SYSDIR}/vcruntime140.dll" DESTINATION ${INSTALL_DESTINATION} OPTIONAL)
457 install(FILES "${WIN_PTHREAD_DLL}" DESTINATION ${INSTALL_DESTINATION})
461 endif() # WIN32 install
463 ############# Packaging ####################
465 # Create Windows installer with NSIS
467 find_program(NSIS_EXE makensis.exe PATHS
468 "C:/Program Files/NSIS"
469 "C:/Program Files (x86)/NSIS"
471 "${WIN_EXTRA_LIBS_PATH}/NSIS"
475 file(TO_NATIVE_PATH "${INSTALL_DESTINATION}" NSIS_DISTRO) # all files in here will be included in installer
476 set(NSI_FILE "${PROJECT_BINARY_DIR}/companion/companion.nsi")
477 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/companion.nsi.in" "${NSI_FILE}" @ONLY)
479 add_custom_target(installer
480 # The 'install' target prepares all the distro files, make sure it has been executed first.
481 COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target install --config Release
482 COMMAND "${NSIS_EXE}" "${NSI_FILE}"
483 DEPENDS "${NSI_FILE}"
484 COMMENT "Building Windows NSIS installer..."
490 set(CPACK_PACKAGE_NAME "companion${C9X_NAME_SUFFIX}")
491 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Models and settings editor for the OpenTX open source firmware")
492 string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
494 # The file stripping is deliberately disabled, with the stripped file we get
495 # very poor trace-backs from the users when they report Companion crash
496 set(CPACK_STRIP_FILES FALSE)
498 # Qt5 + Cmake + Mac is poorly documented. A lot of this is guesswork
499 # and trial and error. Do not hesitate to fix it for the better
501 set(plugin_dest_dir ${COMPANION_NAME}.app/Contents/Plugins)
502 set(qtconf_dest_dir ${COMPANION_NAME}.app/Contents/Resources)
503 set(APPS "\${CMAKE_INSTALL_PREFIX}/${COMPANION_NAME}.app")
504 set(companion_res_dir ${COMPANION_NAME}.app/Contents/Resources)
506 set_target_properties(${COMPANION_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Companion ${VERSION_MAJOR}.${VERSION_MINOR}")
507 set_target_properties(${SIMULATOR_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simulator ${VERSION_MAJOR}.${VERSION_MINOR}")
509 # Use a non standard Info.plist that adds Retina support flags
510 set_target_properties(${COMPANION_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
511 set_target_properties(${SIMULATOR_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/companion/targets/mac/MacOSXBundleInfo.plist.in)
513 INSTALL(TARGETS ${COMPANION_NAME}
514 BUNDLE DESTINATION . COMPONENT Runtime
515 RUNTIME DESTINATION bin COMPONENT Runtime
518 install(FILES ${simulator_plugins} DESTINATION "${companion_res_dir}" COMPONENT Runtime)
520 # Write qt.conf to tell qt where to find it plugins
521 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
522 "[Paths]\nPlugins = Plugins\n")
523 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
524 DESTINATION "${companion_res_dir}"
528 install(DIRECTORY ${PROJECT_SOURCE_DIR}/companion/targets/mac/qt_menu.nib DESTINATION "${companion_res_dir}" COMPONENT Runtime)
530 # manually add the required plugins
531 foreach (plugin ${Qt5Multimedia_PLUGINS} ${Qt5PrintSupport_PLUGINS} ${Qt5Gui_PLUGINS} ${Qt5Svg_PLUGINS})
532 get_target_property(QPA_PLUGIN ${plugin} LOCATION)
533 get_filename_component(QPA_PLUGIN_FILENAME ${QPA_PLUGIN} NAME)
534 # Todo is there a nicer way to get the QT Plugin directory name?!
535 get_filename_component(QPA_PLUGIN_DIRECTORY ${QPA_PLUGIN} DIRECTORY)
536 get_filename_component(QPA_PLUGIN_DIRECTORY ${QPA_PLUGIN_DIRECTORY} NAME)
538 install(FILES ${QPA_PLUGIN} DESTINATION "${plugin_dest_dir}/${QPA_PLUGIN_DIRECTORY}/" COMPONENT Runtime)
540 list(APPEND bundle_qt_libs "\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/${QPA_PLUGIN_DIRECTORY}/${QPA_PLUGIN_FILENAME}")
544 set(MACOSX_BUNDLE_ICON_FILE iconmac.icns)
545 set(MAC_ICON_FILE ${COMPANION_SRC_DIRECTORY}/images/${MACOSX_BUNDLE_ICON_FILE})
546 SET_SOURCE_FILES_PROPERTIES(${MAC_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
547 set(${COMPANION_SOURCES} ${COMPANION_SOURCES} ${PROJECT_SOURCE_DIR}/images/${MACOSX_BUNDLE_ICON_FILE})
548 install(FILES ${MAC_ICON_FILE} DESTINATION ${companion_res_dir} COMPONENT Runtime)
550 # Copy dfu-util and avrdude, resolve symlink first
551 get_filename_component(DFU_UTIL_ABSOLUTE_PATH ${DFU_UTIL_PATH} REALPATH)
552 get_filename_component(AVRDUDE_ABSOLUTE_PATH ${AVRDUDE_PATH} REALPATH)
553 get_filename_component(AVRDUDECONF_ABSOLUTE_PATH ${AVRDUDE_CONF} REALPATH)
554 install(PROGRAMS ${DFU_UTIL_ABSOLUTE_PATH} ${AVRDUDE_ABSOLUTE_PATH} DESTINATION ${companion_res_dir} COMPONENT Runtime)
555 install(FILES ${AVRDUDECONF_ABSOLUTE_PATH} DESTINATION ${companion_res_dir} COMPONENT Runtime)
557 set(bundle_tools_path "\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/dfu-util;\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/avrdude")
560 # Include depencies (adding frameworks, fixing the embbeded libraries)
561 # I get write errors without setting BU_CHMOD_BUNDLE_ITEMS even though it is
562 # technically a hack (that is already is in the Bundle library ...)
564 include(BundleUtilities)
565 file(GLOB bundle_simulator_libs \"\${CMAKE_INSTALL_PREFIX}/${companion_res_dir}/libopentx-*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
566 set(BU_CHMOD_BUNDLE_ITEMS on)
567 fixup_bundle(\"${APPS}\" \"\${bundle_simulator_libs};${bundle_qt_libs};${bundle_tools_path}\" \"${QT_LIB_DIR}\")
568 file(RENAME \"\${CMAKE_INSTALL_PREFIX}/${COMPANION_NAME}.app\" \"\${CMAKE_INSTALL_PREFIX}/${COMPANION_OSX_APP_BUNDLE_NAME}.app\")
572 find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
575 set(CPACK_GENERATOR "DEB")
577 COMMAND ${DPKG_PROGRAM} --print-architecture
578 OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
579 OUTPUT_STRIP_TRAILING_WHITESPACE
581 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
582 set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bertrand Songis <bsongis-nosp@m-gmail.com>")
583 set(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION})
584 set(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
585 set(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
586 set(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR))
587 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins")
588 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
590 set(CPACK_GENERATOR "DragNDrop")
591 # set(CPACK_GENERATOR "TGZ") # for quick testing
592 set(CPACK_BINARY_DRAGNDROP ON)
593 set(CPACK_DMG_BACKGROUND_IMAGE ${COMPANION_SRC_DIRECTORY}/images/splash_dmg.png)
594 set(CPACK_DMG_VOLUME_NAME "OpenTX Companion")
595 set(CPACK_DMG_DS_STORE ${PROJECT_SOURCE_DIR}/companion/targets/mac/DS_Store)
596 set(CPACK_PACKAGE_FILE_NAME "opentx-${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}")
598 set(CPACK_GENERATOR "RPM")
599 set(CPACK_RPM_PACKAGE_VERSION ${VERSION})
600 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
601 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
602 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib /lib/udev /lib/udev/rules.d")