From 726d975ec3dad707be6288de23e82ddf94049717 Mon Sep 17 00:00:00 2001 From: Ruslan Iusupov Date: Tue, 8 Feb 2022 08:55:53 +0100 Subject: [PATCH] Build macOS package with CPack (#256) Co-authored-by: Ruslan Iusupov --- .github/workflows/BuildPR.yml | 10 ++- CMakeLists.txt | 27 ++++--- parser/CMakeLists.txt | 2 +- plugin/CMakeLists.txt | 2 +- qdlt/CMakeLists.txt | 15 ++-- scripts/darwin/Info.plist.in | 38 ++++++++++ scripts/darwin/README.md | 11 +++ scripts/darwin/build.md | 30 ++++++++ scripts/darwin/build.sh | 61 ++++++++++++++++ scripts/darwin/install.md | 18 +++-- scripts/darwin/install.sh | 16 +++++ scripts/darwin/macdeployqt.cmake.in | 45 ++++++++++++ scripts/darwin/package.cmake | 15 ++++ scripts/linux/README.md | 10 ++- scripts/linux/build.md | 4 +- scripts/linux/build.sh | 85 +++++++++------------- scripts/linux/install.md | 15 ++-- scripts/linux/install.sh | 107 ++++++++++++---------------- scripts/linux/linuxdeploy.cmake.in | 15 ++-- scripts/linux/package.cmake | 14 +--- scripts/linux/version.cmake | 9 +++ scripts/windows/README.md | 4 ++ scripts/windows/build.md | 6 +- scripts/windows/install.md | 7 +- src/CMakeLists.txt | 19 +++-- src/cmake/Darwin.cmake | 44 +++++------- src/cmake/Linux.cmake | 6 +- 27 files changed, 428 insertions(+), 207 deletions(-) create mode 100755 scripts/darwin/Info.plist.in create mode 100644 scripts/darwin/README.md create mode 100644 scripts/darwin/build.md create mode 100755 scripts/darwin/build.sh create mode 100755 scripts/darwin/install.sh create mode 100644 scripts/darwin/macdeployqt.cmake.in create mode 100644 scripts/darwin/package.cmake diff --git a/.github/workflows/BuildPR.yml b/.github/workflows/BuildPR.yml index cfcd6e50..f8ed603f 100644 --- a/.github/workflows/BuildPR.yml +++ b/.github/workflows/BuildPR.yml @@ -27,15 +27,15 @@ jobs: - name: Set XCode Version run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app - name: install build environment - run: scripts/linux/install.sh + run: scripts/darwin/install.sh - name: Build project - run: scripts/linux/build.sh + run: scripts/darwin/build.sh - name: Archive artifact uses: actions/upload-artifact@v2.3.1 if: ${{ success() }} with: name: DLTViewer-${{ matrix.macos }}-x86_64 - path: build/dist + path: build/dist/DLTViewer*.tgz buildLinux: name: Build ${{ matrix.ubuntu }} @@ -60,9 +60,7 @@ jobs: if: ${{ success() }} with: name: DLTViewer-linux-x86_64 - path: | - build/dist/DLTViewer*.AppImage - build/dist/*.md + path: build/dist/DLTViewer*.tgz buildWindows: name: Build Windows diff --git a/CMakeLists.txt b/CMakeLists.txt index 55a28cac..889735ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,13 +54,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) get_target_property(DLT_QT5_LIBRARY_PATH Qt5::Core LOCATION) get_filename_component(DLT_QT5_LIB_DIR ${DLT_QT5_LIBRARY_PATH} DIRECTORY) -if(NOT WIN32) - option(DLT_USE_QT_RPATH "Use RPATH for QT_LIBRARY_PATH to support non-standard QT install locations" ON) - if (DLT_USE_QT_RPATH) - # Add Qt to the RPATH, so that there is no need to set LD_LIBRARY_PATH at runtime if Qt is installed in a non-standard location - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${DLT_QT5_LIB_DIR}") - endif() -endif() +# Add Qt to the RPATH, so that there is no need to set LD_LIBRARY_PATH at runtime if Qt is installed in a non-standard location +option(DLT_USE_QT_RPATH "Use RPATH for QT_LIBRARY_PATH to support non-standard QT install locations" ON) # Injection of the GCC-specific compilation flags if(CMAKE_COMPILER_IS_GNUCXX) @@ -73,6 +68,12 @@ add_compile_definitions(QT5) option(DLT_USE_STANDARD_INSTALLATION_LOCATION "Use standard GNU installation locations" OFF) if(NOT WIN32) + if(NOT DLT_APP_DIR_NAME) + set(DLT_APP_DIR_NAME "DLTViewer") + if(APPLE) + set(DLT_APP_DIR_NAME "DLTViewer.app") + endif() + endif() if(DLT_USE_STANDARD_INSTALLATION_LOCATION) include(GNUInstallDirs) set(DLT_PLUGIN_INSTALLATION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/dlt-viewer/plugins") @@ -84,19 +85,22 @@ if(NOT WIN32) set(CMAKE_INSTALL_PREFIX "DLTViewer") endif() if(NOT DLT_PLUGIN_INSTALLATION_PATH) - set(DLT_PLUGIN_INSTALLATION_PATH "usr/bin/plugins") + set(DLT_PLUGIN_INSTALLATION_PATH "${DLT_APP_DIR_NAME}/usr/bin/plugins") endif() if(NOT DLT_RESOURCE_INSTALLATION_PATH) - set(DLT_RESOURCE_INSTALLATION_PATH "usr/share") + set(DLT_RESOURCE_INSTALLATION_PATH "${DLT_APP_DIR_NAME}/usr/share") endif() if(NOT DLT_EXECUTABLE_INSTALLATION_PATH) - set(DLT_EXECUTABLE_INSTALLATION_PATH "usr/bin") + set(DLT_EXECUTABLE_INSTALLATION_PATH "${DLT_APP_DIR_NAME}/usr/bin") endif() if(NOT DLT_LIBRARY_INSTALLATION_PATH) - set(DLT_LIBRARY_INSTALLATION_PATH "usr/lib") + set(DLT_LIBRARY_INSTALLATION_PATH "${DLT_APP_DIR_NAME}/usr/lib") endif() endif() else() + if(NOT DLT_APP_DIR_NAME) + set(DLT_APP_DIR_NAME "./") + endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # AppData is a modern install location. No Admin rights required. file(TO_CMAKE_PATH "$ENV{LOCALAPPDATA}/Programs/dlt-viewer" CMAKE_INSTALL_PREFIX) @@ -137,3 +141,4 @@ message(STATUS "\tDLT_QT5_LIB_DIR: ${DLT_QT5_LIB_DIR}\n") # Must be last include(scripts/windows/package.cmake) include(scripts/linux/package.cmake) +include(scripts/darwin/package.cmake) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index d2004440..3c852f42 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -22,7 +22,7 @@ target_link_libraries(dlt-parser Qt5::Widgets) set_target_properties(dlt-parser PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - INSTALL_RPATH "$ORIGIN/../lib;$<$:${DLT_QT5_LIB_DIR}>") + INSTALL_RPATH "$<$:$ORIGIN/../lib;>$<$:@loader_path/../Frameworks;>$<$:${DLT_QT5_LIB_DIR}>") if(CMAKE_COMPILER_IS_GNUCXX) # https://stackoverflow.com/questions/45329372/ubuntu-recognizes-executable-as-shared-library-and-wont-run-it-by-clicking diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 2d500ba8..7b76e449 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -22,7 +22,7 @@ function(add_plugin NAME) set_target_properties(${NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins - INSTALL_RPATH "$ORIGIN/../../lib;$<$:${DLT_QT5_LIB_DIR}>") + INSTALL_RPATH "$<$:$ORIGIN/../../lib;>$<$:@loader_path/../../Frameworks;>$<$:${DLT_QT5_LIB_DIR}>") install(TARGETS ${NAME} DESTINATION "${DLT_PLUGIN_INSTALLATION_PATH}" diff --git a/qdlt/CMakeLists.txt b/qdlt/CMakeLists.txt index 42a1d4f9..6922802c 100644 --- a/qdlt/CMakeLists.txt +++ b/qdlt/CMakeLists.txt @@ -65,7 +65,7 @@ endif() set_target_properties(qdlt PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - INSTALL_RPATH "$ORIGIN;$<$:${DLT_QT5_LIB_DIR}>") + INSTALL_RPATH "$<$:$ORIGIN;>$<$:@loader_path;>$<$:${DLT_QT5_LIB_DIR}>") install(TARGETS qdlt LIBRARY DESTINATION "${DLT_LIBRARY_INSTALLATION_PATH}" @@ -73,12 +73,19 @@ install(TARGETS qdlt COMPONENT qdlt) # Install QDLT SDK + +if(WIN32) + set(DLT_ADDITIONAL_FILES_INSTALLATION_PATH "${DLT_EXECUTABLE_INSTALLATION_PATH}") +else() + set(DLT_ADDITIONAL_FILES_INSTALLATION_PATH ".") +endif() + install(TARGETS qdlt - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/sdk/lib" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}/sdk/lib" COMPONENT qdlt_sdk) install(DIRECTORY "." - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/sdk/include" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}/sdk/include" COMPONENT qdlt_sdk FILES_MATCHING PATTERN "*.h") @@ -90,6 +97,6 @@ set(SDK_EXAMPLES foreach(SDK_EXAMPLE IN ITEMS ${SDK_EXAMPLES}) install(DIRECTORY "../plugin/${SDK_EXAMPLE}" - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/sdk/src" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}/sdk/src" COMPONENT qdlt_sdk) endforeach() diff --git a/scripts/darwin/Info.plist.in b/scripts/darwin/Info.plist.in new file mode 100755 index 00000000..e49b0bd4 --- /dev/null +++ b/scripts/darwin/Info.plist.in @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + @MACOSX_BUNDLE_EXECUTABLE_NAME@ + CFBundleGetInfoString + @MACOSX_BUNDLE_INFO_STRING@ + CFBundleIconFile + @MACOSX_BUNDLE_ICON_FILE@ + CFBundleIdentifier + @MACOSX_BUNDLE_GUI_IDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + @MACOSX_BUNDLE_LONG_VERSION_STRING@ + CFBundleName + @MACOSX_BUNDLE_BUNDLE_NAME@ + CFBundlePackageType + APPL + CFBundleShortVersionString + @MACOSX_BUNDLE_SHORT_VERSION_STRING@ + CFBundleSignature + ???? + CFBundleVersion + @MACOSX_BUNDLE_BUNDLE_VERSION@ + CSResourcesFileMapped + + NSHumanReadableCopyright + @MACOSX_BUNDLE_COPYRIGHT@ + NSPrincipalClass + NSApplication + NSHighResolutionCapable + + + diff --git a/scripts/darwin/README.md b/scripts/darwin/README.md new file mode 100644 index 00000000..0a9cf0bc --- /dev/null +++ b/scripts/darwin/README.md @@ -0,0 +1,11 @@ +## DLT Viewer on Windows +- [Installation](../windows/install.md) - for regular users +- [Build and contribute](../windows/build.md) - for developers + +## DLT Viewer on Linux +- [Installation](../linux/install.md) - for regular users +- [Build and contribute](../linux/build.md) - for developers + +## DLT Viewer on macOS +- [Installation](./install.md) - for regular users +- [Build and contribute](./build.md) - for developers diff --git a/scripts/darwin/build.md b/scripts/darwin/build.md new file mode 100644 index 00000000..bc69c5b5 --- /dev/null +++ b/scripts/darwin/build.md @@ -0,0 +1,30 @@ +# CMake + MS Visual Studio Code +Please see also [DLT Viewer: CMake + MS Visual Studio Code](../windows/build.md) + +# macOs development environment setup +For DLT Viewer development on **MS Windows** please see [Windows development environment setup](../windows/build.md) +For DLT Viewer development on **Linux** please see [Linux development environment setup](../linux/build.md) + +Configuration: +- macOS Catalina 10.15+ +- Administrator rights `sudo` +- Build environment [install.sh](./install.sh) + - `sudo dlt-viewer/scripts/linux/install.sh` +- MS Visual Studio Code + - https://code.visualstudio.com/docs/setup/mac +- Setup `.vscode` folder + - Copy content of `dlt-viewer/scripts/windows/.vscode_example/*.json` into `dlt-viewer/.vscode/` + - `.vscode` folder contains developer specific settings and not committed to the project. + +# Development with Visual Studio Code +- Please see [windows/build.md](../windows/build.md) on how to use CMake and VS Code with DLT Viewer project. + +# "Build from sources" use-case +- Build Release configuration + - [windows/build.md](../windows/build.md#command-line-build) +- Do NOT use `cmake --install .` for system-wide install. +- Do `cpack -G External` to generate macOS Application bundle. +- Copy/drag DltViewer.app to Applications folder. + +# Build release package +- Same as "Build from sources" use-case. \ No newline at end of file diff --git a/scripts/darwin/build.sh b/scripts/darwin/build.sh new file mode 100755 index 00000000..98b241bc --- /dev/null +++ b/scripts/darwin/build.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -ex + +SRC_DIR=$(pwd) +BUILD_DIR="${SRC_DIR}/build" +INSTALL_DIR="${BUILD_DIR}/install" +APP_DIR_NAME="DLTViewer.app" + +rm -rf "${INSTALL_DIR}" +rm -rf "${SRC_DIR}/build" +mkdir -p "${BUILD_DIR}" +cd "${BUILD_DIR}" + +echo Build with QMake +Qt5_DIR="/usr/local/opt/qt" +qmake ../BuildDltViewer.pro +make + +echo Cleanup +rm -rf "${INSTALL_DIR}" +rm -rf "${SRC_DIR}/build" +mkdir -p "${BUILD_DIR}" +cd "${BUILD_DIR}" + +echo Build with CMake +# Installation paths configuration creates proper macOS Application bundle structure +# https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html +cmake -G Ninja \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ + -DCMAKE_PREFIX_PATH=/opt/qt512/lib/cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DDLT_USE_QT_RPATH=ON \ + -DDLT_PARSER=OFF \ + -DDLT_APP_DIR_NAME=${APP_DIR_NAME} \ + -DDLT_LIBRARY_INSTALLATION_PATH="${APP_DIR_NAME}/Contents/Frameworks" \ + -DDLT_EXECUTABLE_INSTALLATION_PATH="${APP_DIR_NAME}/Contents/MacOS" \ + -DDLT_RESOURCE_INSTALLATION_PATH="${APP_DIR_NAME}/Contents/Resources" \ + -DDLT_PLUGIN_INSTALLATION_PATH="${APP_DIR_NAME}/Contents/MacOS/plugins" \ + "${SRC_DIR}" +cmake --build "${BUILD_DIR}" + +# See src/cmake/Darwin.cmake and scripts/darwin/package.cmake +# +# CPack macOS "Bundle generator" and "DragNDrop Generator" are NOT used. Their functionality is replaced by macdeployqt. +# - https://cmake.org/cmake/help/latest/cpack_gen/bundle.html +# - https://cmake.org/cmake/help/latest/module/CPackDMG.html +# +# External CPack generator calls "cmake --install" and "macdeployqt" +# - https://doc.qt.io/qt-5/macos-deployment.html +# +# CMake install takes care of proper macOs Application bundle setup. Each CMake target has a pre-configured path in bundle. +# macdeployqt copies all used QT5 Frameworks into bundle and patches RPATH in project binaries. +cpack -G External + +cd "${BUILD_DIR}" +FULL_VERSION=$(cat "${BUILD_DIR}/full_version.txt") +echo "FULL_VERSION=${FULL_VERSION}" + +mkdir -p dist +cp ../scripts/darwin/install.md dist +tar -czvf "dist/DLTViewer-${FULL_VERSION}.tgz" -C ${INSTALL_DIR} . diff --git a/scripts/darwin/install.md b/scripts/darwin/install.md index 30b4d854..bb82a224 100644 --- a/scripts/darwin/install.md +++ b/scripts/darwin/install.md @@ -1,9 +1,17 @@ # Installation of DLT Viewer on macOS # Requirements -- Supported platforms - - macOS 10.15.4+ x86 +- Supported platforms: + - macOS Catalina 10.15 x86_64 and later. +- Administrator rights. Needed to override bundle signature. + +# Developer signature override +- DLT Viewer Application bundle is not yet signed. + - You can temporarily override your Mac security settings to open it. + - Go to *Security & Privacy*, click on the lock symbol and choose choose *Anywhere*. + - https://support.apple.com/en-us/HT202491 + - https://www.google.com/search?q=macos+allow+unsigned+application # Installation -## Install QT5 -- `brew install qt@5` -- `brew link qt@5 --force` \ No newline at end of file +- Download and unpack DLT Viewer archive. +- Drag DLTViewer.dmg to Applications folder, making it available in the macOS Launchpad. +- As an alternative DLTViewer.app folder is also included in the archive. diff --git a/scripts/darwin/install.sh b/scripts/darwin/install.sh new file mode 100755 index 00000000..0f28926f --- /dev/null +++ b/scripts/darwin/install.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -ex + +id +env +pwd + +brew install qt@5 +brew link qt@5 --force +# https://github.com/Homebrew/homebrew-core/issues/8392 +# https://github.com/Homebrew/legacy-homebrew/issues/29938 +QT_VERSION=$(brew list --versions qt@5 | sed -n '/qt@5/s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*.*\).*$/\1/p') +sudo ln -s "/usr/local/Cellar/qt@5/${QT_VERSION}/mkspecs" /usr/local/mkspecs +sudo ln -s "/usr/local/Cellar/qt@5/${QT_VERSION}/plugins" /usr/local/plugins + +brew install ninja tree diff --git a/scripts/darwin/macdeployqt.cmake.in b/scripts/darwin/macdeployqt.cmake.in new file mode 100644 index 00000000..5622c552 --- /dev/null +++ b/scripts/darwin/macdeployqt.cmake.in @@ -0,0 +1,45 @@ +set(MACDEPLOYQT_EXECUTABLE "@MACDEPLOYQT_EXECUTABLE@") +set(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") +set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") +set(DLT_APP_DIR_NAME "@DLT_APP_DIR_NAME@") +set(DLT_PLUGIN_INSTALLATION_PATH "@DLT_PLUGIN_INSTALLATION_PATH@") + +# See CMAKE_INSTALL_PREFIX +execute_process(COMMAND ${CMAKE_COMMAND} "--install" "." "--prefix" "${CMAKE_INSTALL_PREFIX}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + RESULT_VARIABLE STATUS) + +if(STATUS AND NOT STATUS EQUAL 0) + message(SEND_ERROR "Failure: ${STATUS}") +else() + message(STATUS "Success.") +endif() + +# execute_process(COMMAND ls -l +# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" +# RESULT_VARIABLE STATUS) + +# execute_process(COMMAND tree +# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" +# RESULT_VARIABLE STATUS) + +file(GLOB DLT_PLUGINS_SO "${CMAKE_INSTALL_PREFIX}/${DLT_PLUGIN_INSTALLATION_PATH}/*.so") +list(TRANSFORM DLT_PLUGINS_SO PREPEND "-executable=") + +message(STATUS "Call ${MACDEPLOYQT_EXECUTABLE} ${DLT_APP_DIR_NAME} ${DLT_PLUGINS_SO}") +execute_process(COMMAND + "${MACDEPLOYQT_EXECUTABLE}" + "${DLT_APP_DIR_NAME}" + -verbose=1 + -always-overwrite + -dmg + -libpath=${CMAKE_INSTALL_PREFIX}/${DLT_APP_DIR_NAME}/Contents/Frameworks + ${DLT_PLUGINS_SO} + WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" + RESULT_VARIABLE STATUS) + +if(STATUS AND NOT STATUS EQUAL 0) + message(SEND_ERROR "Failure: ${STATUS}") +else() + message(STATUS "Success.") +endif() diff --git a/scripts/darwin/package.cmake b/scripts/darwin/package.cmake new file mode 100644 index 00000000..c5ad8808 --- /dev/null +++ b/scripts/darwin/package.cmake @@ -0,0 +1,15 @@ +if(NOT APPLE) + return() +endif() + +# See build.sh and src/cmake/Darwin.cmake +set(CPACK_GENERATOR External) + +get_target_property(MOC_LOCATION Qt5::moc LOCATION) +get_filename_component(MACDEPLOYQT_EXECUTABLE ${MOC_LOCATION}/../macdeployqt ABSOLUTE) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/darwin/macdeployqt.cmake.in" "${CMAKE_BINARY_DIR}/macdeployqt.cmake" @ONLY) + +set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/macdeployqt.cmake") + +# Must be last +include(CPack) diff --git a/scripts/linux/README.md b/scripts/linux/README.md index 8f565c25..d097420f 100644 --- a/scripts/linux/README.md +++ b/scripts/linux/README.md @@ -1,7 +1,11 @@ +## DLT Viewer on Windows +- [Installation](../windows/install.md) - for regular users +- [Build and contribute](../windows/build.md) - for developers + ## DLT Viewer on Linux - [Installation](./install.md) - for regular users - [Build and contribute](./build.md) - for developers -## DLT Viewer on Windows -- [Installation](../windows/install.md) - for regular users -- [Build and contribute](../windows/build.md) - for developers +## DLT Viewer on macOS +- [Installation](../darwin/install.md) - for regular users +- [Build and contribute](../darwin/build.md) - for developers diff --git a/scripts/linux/build.md b/scripts/linux/build.md index 794ca1d8..e2d543d7 100644 --- a/scripts/linux/build.md +++ b/scripts/linux/build.md @@ -32,7 +32,9 @@ sudo apt install code - Please see [windows/build.md](../windows/build.md) on how to use CMake and VS Code with DLT Viewer project. # "Build from sources" use-case -- Build Release configuration and do `cmake --install .` for system-wide install, or `cmake --install . --prefix DLTViewer` for local install. +- Do not use CMake install on Linux and macOS to install DLT Viewer system wide. CMake configuration is aiming Linux AppImage and macOS Application bundle generation. +- If you still need to install DLT Viewer system wide, please use `DLT_USE_STANDARD_INSTALLATION_LOCATION` or provide other installation configuration CMake variables. +- Build Release configuration and do `cmake --install .` for system wide install, or `cmake --install . --prefix DLTViewer` for local install. - Set CMake variable `DLT_USE_STANDARD_INSTALLATION_LOCATION=ON`, see [CMakeLists.txt](../CMakeLists.txt) - OR set `DLT_USE_STANDARD_INSTALLATION_LOCATION=OFF` and use `DLT_XXX_INSTALLATION_PATH` variables, see [build.sh](./build.sh) diff --git a/scripts/linux/build.sh b/scripts/linux/build.sh index 5268f48f..77676c01 100755 --- a/scripts/linux/build.sh +++ b/scripts/linux/build.sh @@ -1,84 +1,67 @@ #!/usr/bin/env bash set -ex -PLATFORM=$(uname -s) -if [[ "${PLATFORM}" == "Darwin" ]]; then - readonly Qt5_DIR="/usr/local/opt/qt" -elif [[ "${PLATFORM}" == "Linux" ]]; then - # https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.12.10-bionic - source /opt/qt512/bin/qt512-env.sh || true -fi +# https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.12.10-bionic +source /opt/qt512/bin/qt512-env.sh || true SRC_DIR=$(pwd) BUILD_DIR="${SRC_DIR}/build" -APP_DIR="${BUILD_DIR}/DLTViewer" +INSTALL_DIR="${BUILD_DIR}/install" +APP_DIR_NAME="DLTViewer" -rm -rf "${APP_DIR}" +rm -rf "${APP_DIR_NAME}" rm -rf "${SRC_DIR}/build" mkdir -p "${BUILD_DIR}" cd "${BUILD_DIR}" -echo Building with QMake +echo Build with QMake qmake ../BuildDltViewer.pro make echo Cleanup -rm -rf "${APP_DIR}" +rm -rf "${INSTALL_DIR}" rm -rf "${SRC_DIR}/build" mkdir -p "${BUILD_DIR}" cd "${BUILD_DIR}" -echo Building with CMake - +echo Build with CMake cmake -G Ninja \ - -DCMAKE_INSTALL_PREFIX=DLTViewer \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ -DCMAKE_PREFIX_PATH=/opt/qt512/lib/cmake \ -DCMAKE_BUILD_TYPE=Release \ -DDLT_USE_QT_RPATH=ON \ -DDLT_PARSER=OFF \ - -DDLT_LIBRARY_INSTALLATION_PATH="usr/lib" \ - -DDLT_EXECUTABLE_INSTALLATION_PATH="usr/bin" \ - -DDLT_RESOURCE_INSTALLATION_PATH="usr/share" \ - -DDLT_PLUGIN_INSTALLATION_PATH="usr/bin/plugins" \ + -DDLT_APP_DIR_NAME=${APP_DIR_NAME} \ + -DDLT_LIBRARY_INSTALLATION_PATH="${APP_DIR_NAME}/usr/lib" \ + -DDLT_EXECUTABLE_INSTALLATION_PATH="${APP_DIR_NAME}/usr/bin" \ + -DDLT_RESOURCE_INSTALLATION_PATH="${APP_DIR_NAME}/usr/share" \ + -DDLT_PLUGIN_INSTALLATION_PATH="${APP_DIR_NAME}/usr/bin/plugins" \ "${SRC_DIR}" cmake --build "${BUILD_DIR}" -v +# External CPack generator calls "cmake --install" and "linuxdeploy" +# # CMake install takes care of proper AppDir setup. Each CMake target has a pre-configured path. -cmake --install "${BUILD_DIR}" --prefix "${APP_DIR}" +# - https://github.com/linuxdeploy/linuxdeploy +# - https://github.com/AppImage/appimagekit +# +# linuxdeploy will establish relative DT_RUNPATH: $ORIGIN/../lib inside each binary file. +# https://docs.appimage.org/reference/best-practices.html#general-recommendations +# https://docs.appimage.org/packaging-guide/from-source/native-binaries.html +# DT_RUNPATH https://linux.die.net/man/1/ld +# could be checked with `objdump -p` -cd "${BUILD_DIR}" -mkdir -p dist +# sudo chown -R 1000:1000 "${SRC_DIR}/build" +# sudo chmod -R a+rw "${SRC_DIR}/build" +# linuxdeploy is wrapped in CPack External generator. See linux/package.cmake +# Please note, other CPack generators will NOT call linuxdeploy, therefore they will produce non-relocatable package. +cpack -G External + +cd "${BUILD_DIR}" FULL_VERSION=$(cat "${BUILD_DIR}/full_version.txt") echo "FULL_VERSION=${FULL_VERSION}" -if [[ "${PLATFORM}" == 'Darwin' ]]; then - echo TODO Use macdeployqt https://doc.qt.io/qt-5/macos-deployment.html - # AppDir archive - tar -czvf "DLTViewer-${FULL_VERSION}.tgz" DLTViewer - cp DLTViewer*.tgz dist - cp ../scripts/darwin/install.md dist -elif [[ "${PLATFORM}" == "Linux" ]]; then - cd "${BUILD_DIR}" - # pwd - # ls -la - # https://github.com/linuxdeploy/linuxdeploy - # https://github.com/AppImage/appimagekit - - # linuxdeploy will establish relative DT_RUNPATH: $ORIGIN/../lib inside each binary file. - # https://docs.appimage.org/reference/best-practices.html#general-recommendations - # https://docs.appimage.org/packaging-guide/from-source/native-binaries.html - # DT_RUNPATH https://linux.die.net/man/1/ld - # could be checked with `objdump -p` - - # sudo chown -R 1000:1000 "${SRC_DIR}/build" - # sudo chmod -R a+rw "${SRC_DIR}/build" - - # linuxdeploy is wrapped in CPack External generator. See linux/package.cmake - # Please note, other CPack generators will NOT call linuxdeploy, therefore they will produce non-relocatable package. - cpack -G External - - mkdir -p dist - cp DLTViewer*.AppImage dist - cp ../scripts/linux/install.md dist -fi +mkdir -p dist +cp ../scripts/linux/install.md dist +tar -czvf "dist/DLTViewer-${FULL_VERSION}.tgz" -C ${INSTALL_DIR} . diff --git a/scripts/linux/install.md b/scripts/linux/install.md index f57e737a..fe7e9a6a 100644 --- a/scripts/linux/install.md +++ b/scripts/linux/install.md @@ -1,11 +1,11 @@ # Installation of DLT Viewer on Linux # Requirements - Supported platforms - - Ubuntu 18.04+ - - In general any common desktop Linux distribution with **glibc >= 2.27** should be supported. + - Ubuntu 18.04 x86_64 and later. + - Most of modern desktop Linux distributions with **glibc >= 2.27**. - `ldd --version` - Administrator rights `sudo` are **not needed** -- No need to download and install C++ build tools, QT framework **or any other dependencies**. +- No need to download and install C++ build tools, QT framework **or any other dependencies**, they are included in AppImage. # AppImage - AppImage files are simpler than installing an application. No extraction tools are needed, nor is it necessary to modify the operating system or user environment. Regular users on the common Linux distributions can download it, make it executable, and run it. [Wikipedia](https://en.wikipedia.org/wiki/AppImage) @@ -14,14 +14,15 @@ # Installation - https://docs.appimage.org/user-guide/faq.html -- Download and unpack DLT Viewer AppImage. - - Download AppImage into `~/bin/` +- Download and unpack DLT Viewer archive. + - Copy AppImage into `~/bin/` - Make it executable and run - `chmod +x ~/bin/DLT_Viewer-2.21.3-x86_64.AppImage` - https://discourse.appimage.org/t/how-to-run-an-appimage/80 - https://docs.appimage.org/user-guide/run-appimages.html - Command line mode of DLT Viewer also works in terminal - `./DLT_Viewer-2.21.3-x86_64.AppImage --help` + ## Troubleshooting - AppImage on start creates filesystem mount to `/tmp` using user space FUSE driver. If FUSE is not available, AppImage can be instructed to simply unpack into `/tmp` - `./DLT_Viewer-2.21.3-x86_64.AppImage --appimage-extract-and-run` @@ -32,12 +33,14 @@ - This command can mount AppImage `~/bin/DLT_Viewer-2.21.3-x86_64.AppImage --appimage-mount` - AppImage help - `~/bin/DLT_Viewer-2.21.3-x86_64.AppImage --appimage-help` + ## Optional desktop integration ### Automatic integration - Modern Linux distributions, like Manjaro, already include AppImageLauncher. This will display dialog to integrate AppImage into desktop automatically. - Also there is a daemon [appimaged](https://github.com/probonopd/go-appimage), which can take care of AppImage. + ### Manual integration -- Download AppImage into `~/bin` and make it executable +- Copy AppImage into `~/bin` and make it executable - `chmod +x ~/bin/DLT_Viewer-2.21.3-x86_64.AppImage` - Mount AppImage - `~/bin/DLT_Viewer-2.21.3-x86_64.AppImage --appimage-mount` diff --git a/scripts/linux/install.sh b/scripts/linux/install.sh index 5642b216..b9ea25f5 100755 --- a/scripts/linux/install.sh +++ b/scripts/linux/install.sh @@ -5,63 +5,50 @@ id env pwd -PLATFORM=$(uname -s) -if [[ "${PLATFORM}" == 'Darwin' ]]; then - brew install qt@5 - brew link qt@5 --force - # https://github.com/Homebrew/homebrew-core/issues/8392 - # https://github.com/Homebrew/legacy-homebrew/issues/29938 - QT_VERSION=$(brew list --versions qt@5 | sed -n '/qt@5/s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*.*\).*$/\1/p') - sudo ln -s "/usr/local/Cellar/qt@5/${QT_VERSION}/mkspecs" /usr/local/mkspecs - sudo ln -s "/usr/local/Cellar/qt@5/${QT_VERSION}/plugins" /usr/local/plugins - - brew install ninja -elif [[ "${PLATFORM}" == "Linux" ]]; then - sudo apt update - sudo apt-get install -y --no-install-recommends apt-utils - sudo apt install -y wget unzip software-properties-common lsb-release openssh-client curl - - # QT 5.12.10, is installed into /opt/qt512/ - sudo touch /etc/apt/sources.list - sudo add-apt-repository -y ppa:beineri/opt-qt-5.12.10-$(lsb_release -cs) - - # Latest cmake for current platform - sudo wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" - - # GCC 11 - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - - sudo apt update - sudo apt install -y git cmake build-essential ninja-build \ - qt512declarative qt512serialport qt512charts-no-lgpl qt512svg \ - libgtk2.0-dev libgl-dev gcc-11 g++-11 - - sudo update-alternatives --remove-all cpp - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 --slave /usr/bin/cpp cpp /usr/bin/cpp-11 - - sudo gcc --version && g++ --version && gcov --version - sudo update-alternatives --config gcc - - # https://askubuntu.com/questions/616065/the-imported-target-qt5gui-references-the-file-usr-lib-x86-64-linux-gnu-li - sudo ln -f /usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so - - mkdir -p ~/bin - wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" -O ~/bin/linuxdeploy - chmod a+x ~/bin/linuxdeploy - - wget -c -nv "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" -O ~/bin/linuxdeploy-plugin-qt - chmod a+x ~/bin/linuxdeploy-plugin-qt - - # QT GTK+ 2 Plugins - # https://github.com/probonopd/linuxdeployqt/issues/338 - # https://github.com/probonopd/linuxdeployqt/issues/355 - # https://github.com/probonopd/linuxdeployqt/issues/60 - cd /opt - git clone http://code.qt.io/qt/qtstyleplugins.git - cd qtstyleplugins - /opt/qt512/bin/qmake - make -j$(nproc) - sudo make install - rm -rf /opt/qtstyleplugins -fi +sudo apt update +sudo apt-get install -y --no-install-recommends apt-utils +sudo apt install -y wget unzip software-properties-common lsb-release openssh-client curl + +# QT 5.12.10, is installed into /opt/qt512/ +sudo touch /etc/apt/sources.list +sudo add-apt-repository -y ppa:beineri/opt-qt-5.12.10-$(lsb_release -cs) + +# Latest cmake for current platform +sudo wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null +sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" + +# GCC 11 +sudo add-apt-repository ppa:ubuntu-toolchain-r/test + +sudo apt update +sudo apt install -y git cmake build-essential ninja-build \ + qt512declarative qt512serialport qt512charts-no-lgpl qt512svg \ + libgtk2.0-dev libgl-dev gcc-11 g++-11 + +sudo update-alternatives --remove-all cpp +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 --slave /usr/bin/cpp cpp /usr/bin/cpp-11 + +sudo gcc --version && g++ --version && gcov --version +sudo update-alternatives --config gcc + +# https://askubuntu.com/questions/616065/the-imported-target-qt5gui-references-the-file-usr-lib-x86-64-linux-gnu-li +sudo ln -f /usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so + +mkdir -p ~/bin +wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" -O ~/bin/linuxdeploy +chmod a+x ~/bin/linuxdeploy + +wget -c -nv "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" -O ~/bin/linuxdeploy-plugin-qt +chmod a+x ~/bin/linuxdeploy-plugin-qt + +# QT GTK+ 2 Plugins +# https://github.com/probonopd/linuxdeployqt/issues/338 +# https://github.com/probonopd/linuxdeployqt/issues/355 +# https://github.com/probonopd/linuxdeployqt/issues/60 +cd /opt +git clone http://code.qt.io/qt/qtstyleplugins.git +cd qtstyleplugins +/opt/qt512/bin/qmake +make -j$(nproc) +sudo make install +rm -rf /opt/qtstyleplugins diff --git a/scripts/linux/linuxdeploy.cmake.in b/scripts/linux/linuxdeploy.cmake.in index 1f8ab9b4..785c771c 100644 --- a/scripts/linux/linuxdeploy.cmake.in +++ b/scripts/linux/linuxdeploy.cmake.in @@ -3,13 +3,14 @@ set(QMAKE_EXECUTABLE "@QMAKE_EXECUTABLE@") set(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") set(CPACK_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@") +set(DLT_APP_DIR_NAME "@DLT_APP_DIR_NAME@") message(STATUS "Calling linuxdeploy ${CMAKE_INSTALL_PREFIX}") message(STATUS "QMAKE=${QMAKE_EXECUTABLE}") # See CMAKE_INSTALL_PREFIX execute_process(COMMAND ${CMAKE_COMMAND} "--install" "." "--prefix" "${CMAKE_INSTALL_PREFIX}" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" RESULT_VARIABLE STATUS) if(STATUS AND NOT STATUS EQUAL 0) @@ -32,14 +33,14 @@ execute_process(COMMAND "${LINUXDEPLOY_EXECUTABLE}" --plugin qt --output appimage - --appdir ${CMAKE_INSTALL_PREFIX} - --executable ${CMAKE_INSTALL_PREFIX}/usr/bin/dlt-viewer - --deploy-deps-only ${CMAKE_INSTALL_PREFIX}/usr/bin/plugins - --desktop-file ${CMAKE_INSTALL_PREFIX}/dlt-viewer.desktop - --icon-file ${CMAKE_INSTALL_PREFIX}/dlt-viewer.png + --appdir ${DLT_APP_DIR_NAME} + --executable ${DLT_APP_DIR_NAME}/usr/bin/dlt-viewer + --deploy-deps-only ${DLT_APP_DIR_NAME}/usr/bin/plugins + --desktop-file ${DLT_APP_DIR_NAME}/dlt-viewer.desktop + --icon-file ${DLT_APP_DIR_NAME}/dlt-viewer.png --library /usr/lib/x86_64-linux-gnu/libstdc++.so.6 --library /lib/x86_64-linux-gnu/libgcc_s.so.1 - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" RESULT_VARIABLE STATUS) if(STATUS AND NOT STATUS EQUAL 0) diff --git a/scripts/linux/package.cmake b/scripts/linux/package.cmake index 2d8a7834..9c125d5a 100644 --- a/scripts/linux/package.cmake +++ b/scripts/linux/package.cmake @@ -2,17 +2,7 @@ if(NOT LINUX) return() 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 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${DLT_VERSION_SUFFIX}") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") - -set(CPACK_PACKAGE_INSTALL_DIRECTORY "DLTViewer") -set(CPACK_PACKAGE_NAME "DLTViewer") -set(CPACK_PACKAGE_VENDOR "COVESA") -set(CPACK_PACKAGE_EXECUTABLES "dlt-viewer" "DLT Viewer") +set(CPACK_PACKAGE_VERSION "${DLT_PROJECT_VERSION_MAJOR}.${DLT_PROJECT_VERSION_MINOR}.${DLT_PROJECT_VERSION_PATCH}-${DLT_VERSION_SUFFIX}") # Linuxdeploy wrapped in external CPack generator # https://cmake.org/cmake/help/v3.15/cpack_gen/external.html @@ -22,7 +12,7 @@ set(CPACK_GENERATOR External) # Linuxdeploy is mandatory, other packages are non relocatable # See install.sh find_program(LINUXDEPLOY_EXECUTABLE linuxdeploy HINTS "~/bin") -find_program(LINUXDEPLOY_PLUGIN_QT_EXECUTABLE linuxdeploy-plugin-qt HINTS "~/bin") +# find_program(LINUXDEPLOY_PLUGIN_QT_EXECUTABLE linuxdeploy-plugin-qt HINTS "~/bin") find_program(QMAKE_EXECUTABLE qmake HINTS "/opt/qt512/bin") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/linux/linuxdeploy.cmake.in" "${CMAKE_BINARY_DIR}/linuxdeploy.cmake" @ONLY) diff --git a/scripts/linux/version.cmake b/scripts/linux/version.cmake index 04d78bd8..f22da7be 100644 --- a/scripts/linux/version.cmake +++ b/scripts/linux/version.cmake @@ -33,6 +33,11 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE RESULT ) +if(RESULT AND NOT RESULT EQUAL 0) + message(SEND_ERROR "Failure: ${RESULT}") +else() + message(RESULT "Success.") +endif() execute_process( COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/linux/parse_version.sh" "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h" PACKAGE_MINOR_VERSION @@ -48,4 +53,8 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) +if("${CMAKE_CXX_LIBRARY_ARCHITECTURE}" STREQUAL "") + set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64") +endif() + set(DLT_VERSION_SUFFIX "STABLE-qt${DLT_QT5_VERSION}-r${GIT_PATCH_VERSION}_${CMAKE_CXX_LIBRARY_ARCHITECTURE}_${CMAKE_CXX_COMPILER_VERSION}") diff --git a/scripts/windows/README.md b/scripts/windows/README.md index e214cfd3..75acb33c 100644 --- a/scripts/windows/README.md +++ b/scripts/windows/README.md @@ -5,3 +5,7 @@ ## DLT Viewer on Linux - [Installation](../linux/install.md) - for regular users - [Build and contribute](../linux/build.md) - for developers + +## DLT Viewer on macOS +- [Installation](../darwin/install.md) - for regular users +- [Build and contribute](../darwin/build.md) - for developers diff --git a/scripts/windows/build.md b/scripts/windows/build.md index 79209527..fbfb8048 100644 --- a/scripts/windows/build.md +++ b/scripts/windows/build.md @@ -185,12 +185,13 @@ cmake --build . --target dltsomeipplugin -v - dlt-viewer - `option(DLT_PARSER "Build DLT Parser" OFF)` - `option(DLT_DUMMY_PLUGINS "Build Dummy plugins" OFF)` - - Linux only: - - `option(DLT_USE_STANDARD_INSTALLATION_LOCATION "Use standard GNU installation locations" OFF)` + - Linux and macOs only: + - `option(DLT_USE_STANDARD_INSTALLATION_LOCATION "Use standard GNU installation locations" OFF)` - `set(DLT_PLUGIN_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/dlt-viewer/plugins)` - `set(DLT_RESOURCE_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_DATADIR}/dlt-viewer)` - `set(DLT_EXECUTABLE_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_BINDIR})` - `set(DLT_LIBRARY_INSTALLATION_PATH ${CMAKE_INSTALL_FULL_LIBDIR})` + - `set(DLT_APP_DIR_NAME "DLTViewer")` for Linux, `set(DLT_APP_DIR_NAME "DLTViewer.app")` for macOS - `option(DLT_USE_QT_RPATH "Use RPATH for QT_LIBRARY_PATH to support non-standard QT install locations" ON)` ## CMake targets - See "CMake: Project outline" on the left in VS Code @@ -222,6 +223,7 @@ cmake --build . --target dltsomeipplugin -v ## CMake install - `cmake install . --prefix C:\DltViewerSDK` command replaces old approach with `.bat` files to prepare DLT Viewer distribution. - Each CMake target is configured with additional files, which belongs to it. This allows to reduce amount of scripts and simplify maintenance of cross platform development. +- Do not use CMake install on Linux and macOS to install DLT Viewer system wide. CMake configuration is aiming AppImage and macOS bundle generation. ## CPack - [CPack](https://cmake.org/cmake/help/latest/module/CPack.html) is a separate command line utility, part of CMake. - CPack uses same concept of generators to produce specific build artifact. diff --git a/scripts/windows/install.md b/scripts/windows/install.md index 859f345c..5b670a59 100644 --- a/scripts/windows/install.md +++ b/scripts/windows/install.md @@ -1,11 +1,12 @@ # Installation of DLT Viewer on Windows # Requirements - Supported platforms - - Windows 7 x64 - - Windows 10 x64 - - Windows 11 x64 + - Windows 7 x86_64 + - Windows 10 x86_64 + - Windows 11 x86_64 - Administrator rights are **not needed** - No need to download and install QT framework. + # Installation - Install **Microsoft Visual C++ 2017 Redistributable (x64)** or later - Download **latest package** from [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c15acff..643f2a50 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,31 +63,38 @@ endif() set_target_properties(dlt-viewer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin - INSTALL_RPATH "$ORIGIN/../lib;$<$:${DLT_QT5_LIB_DIR}>") + INSTALL_RPATH "$<$:$ORIGIN/../lib;>$<$:@loader_path/../Frameworks;>$<$:${DLT_QT5_LIB_DIR}>") -install(TARGETS dlt-viewer + install(TARGETS dlt-viewer DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}" # Underscore for NSIS compatibility https://gitlab.kitware.com/cmake/cmake/-/issues/19982 COMPONENT dlt_viewer) +if(WIN32) + set(DLT_ADDITIONAL_FILES_INSTALLATION_PATH "${DLT_EXECUTABLE_INSTALLATION_PATH}") +else() + set(DLT_ADDITIONAL_FILES_INSTALLATION_PATH ".") +endif() + install(FILES ../LICENSE.txt ../MPL.txt ../README.md ../ReleaseNotes_Viewer.txt - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}" COMPONENT dlt_viewer) install(FILES ../doc/dlt_viewer_user_manual.pdf ../doc/dlt_viewer_plugins_programming_guide.pdf - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/doc" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}/doc" COMPONENT documentation) install(DIRECTORY ../filters - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}" COMPONENT dlt_viewer) install(DIRECTORY ../plugin/examples - DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/plugins" + DESTINATION "${DLT_ADDITIONAL_FILES_INSTALLATION_PATH}/plugins" COMPONENT dlt_viewer) + include(cmake/${CMAKE_SYSTEM_NAME}.cmake OPTIONAL) diff --git a/src/cmake/Darwin.cmake b/src/cmake/Darwin.cmake index a06da2d3..9610e832 100644 --- a/src/cmake/Darwin.cmake +++ b/src/cmake/Darwin.cmake @@ -1,28 +1,22 @@ -# set some properties for the bundle Info.plist file -set (MACOSX_BUNDLE_BUNDLE_NAME "DLT Viewer" ) -set (MACOSX_BUNDLE_SHORT_VERSION_STRING ${PACKAGE_VERSION} ) -set (MACOSX_BUNDLE_GUI_IDENTIFIER "org.genivi.dlt-viewer") -set (MACOSX_BUNDLE_ICON_FILE icon) +# set properties for the bundle Info.plist file +set(MACOSX_BUNDLE_EXECUTABLE_NAME "dlt-viewer") +set(MACOSX_BUNDLE_INFO_STRING "DLT Viewer") +set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${DLT_PROJECT_VERSION_MAJOR}.${DLT_PROJECT_VERSION_MINOR}.${DLT_PROJECT_VERSION_PATCH}") +set(MACOSX_BUNDLE_BUNDLE_VERSION "${MACOSX_BUNDLE_SHORT_VERSION_STRING}") +set(MACOSX_BUNDLE_LONG_VERSION_STRING "${MACOSX_BUNDLE_SHORT_VERSION_STRING}-${DLT_VERSION_SUFFIX}") +set(MACOSX_BUNDLE_BUNDLE_NAME "DLT Viewer") +set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.genivi.dlt-viewer") +set(MACOSX_BUNDLE_ICON_FILE icon) +set(MACOSX_BUNDLE_COPYRIGHT "Copyright (C) 2016, BMW AG - Alexander Wenzel <alexander.aw.wenzel@bmw.de>") -# configure the bundle icon file -set (ICON resources/icon/icon.icns) -set_property (SOURCE ${ICON} PROPERTY MACOSX_PACKAGE_LOCATION Resources) -target_sources (dlt-viewer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${ICON}) +install(FILES + resources/icon/icon.icns + DESTINATION "${DLT_RESOURCE_INSTALLATION_PATH}" + COMPONENT dlt_viewer) -# set the executable target to be built as macOS app bundle -set_target_properties (dlt-viewer PROPERTIES - MACOSX_BUNDLE True - OUTPUT_NAME "DLT Viewer") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/darwin/Info.plist.in" "${CMAKE_BINARY_DIR}/Info.plist" @ONLY) -# get the path for the macdeployqt tool -get_target_property(MOC_LOCATION Qt5::moc LOCATION) -get_filename_component(MAC_DEPLOY_TOOL ${MOC_LOCATION}/../macdeployqt ABSOLUTE) - -# convert the target into a self contained app bundle -add_custom_command(TARGET dlt-viewer POST_BUILD - COMMAND ${MAC_DEPLOY_TOOL} $/../.. -always-overwrite) - -# enable high-DPI displays support -add_custom_command(TARGET dlt-viewer POST_BUILD - COMMAND plutil -replace NSPrincipalClass -string NSApplication $/../Info.plist - COMMAND plutil -replace NSHighResolutionCapable -bool true $/../Info.plist) +install(PROGRAMS + "${CMAKE_BINARY_DIR}/Info.plist" + DESTINATION "${DLT_EXECUTABLE_INSTALLATION_PATH}/.." + COMPONENT dlt_viewer) diff --git a/src/cmake/Linux.cmake b/src/cmake/Linux.cmake index 5a34d975..db31180a 100644 --- a/src/cmake/Linux.cmake +++ b/src/cmake/Linux.cmake @@ -12,12 +12,12 @@ install(FILES COMPONENT dlt_viewer) install(FILES "resources/icon/256x256/org.genivi.DLTViewer.png" - DESTINATION "." + DESTINATION "${DLT_APP_DIR_NAME}" RENAME ".DirIcon" COMPONENT dlt_viewer) install(FILES "resources/icon/256x256/org.genivi.DLTViewer.png" - DESTINATION "." + DESTINATION "${DLT_APP_DIR_NAME}" RENAME "dlt-viewer.png" COMPONENT dlt_viewer) @@ -28,5 +28,5 @@ install(PROGRAMS COMPONENT dlt_viewer) install(PROGRAMS "resources/dlt-viewer.desktop" - DESTINATION "." + DESTINATION "${DLT_APP_DIR_NAME}" COMPONENT dlt_viewer)