diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh deleted file mode 100755 index 7c917fdab..000000000 --- a/.github/scripts/build.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# set environment variables if not exists -[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Debug" -[ -z "${TARGET_ARCH}" ] && TARGET_ARCH="linux/amd64" -[ -z "${PLATFORM}" ] && PLATFORM="x11" - -# Determine cmake build type; tag builds are Release, else Debug (-dev appends to platform) -if [[ $GITHUB_REF == *"refs/tags"* ]]; then - BUILD_TYPE=Release -else - PLATFORM=${PLATFORM}-dev -fi - -echo "Compile Hyperion on '${RUNNER_OS}' with build type '${BUILD_TYPE}' and platform '${PLATFORM}'" - -# Build the package on MacOS, Windows or Linux -if [[ "$RUNNER_OS" == 'macOS' ]]; then - mkdir build || exit 1 - cmake -B build -G Ninja -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=/usr/local || exit 2 - cmake --build build --target package --parallel $(sysctl -n hw.ncpu) || exit 3 - cd ${GITHUB_WORKSPACE} && source /${GITHUB_WORKSPACE}/test/testrunner.sh || exit 4 - exit 0; - exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 5; } -elif [[ $RUNNER_OS == "Windows" ]]; then - echo "Number of Cores $NUMBER_OF_PROCESSORS" - mkdir build || exit 1 - cd build - cmake -G "Visual Studio 17 2022" -A x64 -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE="Release" ../ || exit 2 - cmake --build . --target package --config "Release" -- -nologo -v:m -maxcpucount || exit 3 - exit 0; - exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 5; } -elif [[ "$RUNNER_OS" == 'Linux' ]]; then - echo "Docker arguments used: DOCKER_IMAGE=${DOCKER_IMAGE}, DOCKER_TAG=${DOCKER_TAG}, TARGET_ARCH=${TARGET_ARCH}" - # verification bypass of external dependencies - # set GitHub Container Registry url - REGISTRY_URL="ghcr.io/hyperion-project/${DOCKER_IMAGE}" - # take ownership of deploy dir - mkdir ${GITHUB_WORKSPACE}/deploy - - # run docker - docker run --rm --platform=${TARGET_ARCH} \ - -v "${GITHUB_WORKSPACE}/deploy:/deploy" \ - -v "${GITHUB_WORKSPACE}:/source:rw" \ - $REGISTRY_URL:$DOCKER_TAG \ - /bin/bash -c "mkdir -p /source/build && cd /source/build && - cmake -G Ninja -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. || exit 2 && - cmake --build . --target package -- -j $(nproc) || exit 3 || : && - cp /source/build/bin/h* /deploy/ 2>/dev/null || : && - cp /source/build/Hyperion-* /deploy/ 2>/dev/null || : && - cd /source && source /source/test/testrunner.sh || exit 5 && - exit 0; - exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 5; } - - # overwrite file owner to current user - sudo chown -fR $(stat -c "%U:%G" ${GITHUB_WORKSPACE}/deploy) ${GITHUB_WORKSPACE}/deploy -fi diff --git a/.github/workflows/qt5_6.yml b/.github/workflows/qt5_6.yml index ac0889528..70124cbe9 100644 --- a/.github/workflows/qt5_6.yml +++ b/.github/workflows/qt5_6.yml @@ -25,9 +25,6 @@ on: default: false required: false -env: - ghcr: hyperion-project - jobs: ###################### @@ -36,7 +33,7 @@ jobs: Linux: name: 🐧 ${{ matrix.os.description }} - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.os.architecture[0] == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }} strategy: fail-fast: false matrix: @@ -49,6 +46,7 @@ jobs: { distribution: debian, codename: bullseye, description: Debian Bullseye (Raspberry Pi 2), architecture: [ armv7, linux/arm/v7 ], platform: rpi }, { distribution: debian, codename: bullseye, description: Debian Bullseye (Raspberry Pi 3/4/5 & Zero 2), architecture: [ arm64, linux/arm64 ], platform: rpi } ] + target_lookup: [{ 'arm64': 'arm64', 'armv6': 'armv6l', 'armv7': 'armv7l' }] isQt5: - ${{ inputs.qt_version == '5' }} exclude: @@ -63,24 +61,29 @@ jobs: with: submodules: recursive - - name: 🔧 Prepare + - name: 🔧 Append PR number to version (PR only) + if: ${{ inputs.event_name == 'pull_request' }} shell: bash - run: | - echo '::group::Append PR number to version (PR only)' - if [[ "${{ inputs.event_name }}" = "pull_request" ]]; then - tr -d '\n' < .version > temp && mv temp .version - echo -n "+PR${{ inputs.pull_request_number }}" >> .version - fi - echo '::endgroup::' + run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version - name: 👷 Build shell: bash - run: ./.github/scripts/build.sh + run: | + mkdir deploy + docker run --rm --platform=${{ matrix.os.architecture[1] }} ${{ env.ENTRYPOINT }} \ + -v "${{ github.workspace }}/deploy:/deploy" \ + -v "${{ github.workspace }}:/source:rw" \ + -w "/source" \ + ghcr.io/hyperion-project/${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} \ + /bin/bash -c "cmake --preset linux-${{ env.BUILD_TYPE }} -DPLATFORM=${{ matrix.os.platform }} ${{ env.CPACK_SYSTEM_PROCESSOR }} && + cmake --build --preset linux-${{ env.BUILD_TYPE }} --target package --parallel $(nproc) && + cp /source/build/Hyperion-* /deploy/ 2>/dev/null" env: DOCKER_IMAGE: ${{ matrix.os.distribution }} DOCKER_TAG: ${{ matrix.os.codename }}${{ inputs.qt_version == '6' && '-qt6' || '' }} - PLATFORM: ${{ matrix.os.platform }} - TARGET_ARCH: ${{ matrix.os.architecture[1] }} + BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }} + ENTRYPOINT: ${{ matrix.os.architecture[0] != 'amd64' && '--entrypoint /usr/bin/env' || '' }} + CPACK_SYSTEM_PROCESSOR: ${{ matrix.os.architecture[0] != 'amd64' && format('-DCPACK_SYSTEM_PROCESSOR={0}', matrix.target_lookup[format('{0}', matrix.os.architecture[0])]) || '' }} - name: 📦 Upload if: ${{ inputs.publish || inputs.event_name == 'pull_request' }} @@ -96,40 +99,44 @@ jobs: ###################### macOS: - name: 🍏 macOS x64 - runs-on: macos-latest + name: 🍏 macOS ${{ matrix.architecture }} + runs-on: ${{ matrix.architecture == 'arm64' && 'macos-14' || 'macos-13' }} + strategy: + fail-fast: false + matrix: + architecture: [ arm64, x64 ] + steps: - name: ⬇ Checkout uses: actions/checkout@v4 with: submodules: recursive - - name: 🔧 Prepare + - name: 🔧 Append Pull Request number to version (PR only) + if: ${{ inputs.event_name == 'pull_request' }} shell: bash - run: | - echo '::group::Append PR number to version (PR only)' - if [[ "${{ inputs.event_name }}" = "pull_request" ]]; then - tr -d '\n' < .version > temp && mv temp .version - echo -n "+PR${{ inputs.pull_request_number }}" >> .version - fi - echo '::endgroup::' + run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version - echo '::group::Update/Install dependencies' - brew untap --force homebrew/core homebrew/cask - brew update || true - brew install qt@${{ inputs.qt_version }} vulkan-headers ninja libftdi || true - echo '::endgroup::' - - - name: Temporarily downgrade CMake to 3.28.3 # Please remove if GitHub has updated Cmake (greater than 3.30.0) - uses: jwlawson/actions-setup-cmake@v2 + - name: 📥 Install dependencies + uses: tecolicom/actions-use-homebrew-tools@v1 with: - cmake-version: '3.28.3' + tools: qt@${{ inputs.qt_version }} vulkan-headers ninja libftdi + key: ${{ runner.os }}-${{ matrix.architecture }}-homebrew-packages-${{ inputs.qt_version }} - name: 👷 Build shell: bash - run: ./.github/scripts/build.sh + run: | + # Remove once issue with hombrew cache action is fixed + brew reinstall --formula cmake + # Build + cmake --preset macos-${{ env.BUILD_TYPE }} + cmake --build --preset macos-${{ env.BUILD_TYPE }} --parallel $(sysctl -n hw.ncpu) + # CPack workaround for macOS 13 + echo killing...; sudo pkill -9 XProtect >/dev/null || true; + echo waiting...; while pgrep XProtect; do sleep 3; done; + cd build; cpack env: - PLATFORM: osx + BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }} - name: 📦 Upload if: ${{ inputs.publish || inputs.event_name == 'pull_request' }} @@ -138,7 +145,7 @@ jobs: name: ${{ inputs.event_name == 'pull_request' && env.NAME || format('artifact-{0}', env.NAME) }} path: 'build/Hyperion-*' env: - NAME: ${{ inputs.qt_version == '6' && 'macOS_x64_qt6' || 'macOS_x64' }} + NAME: ${{ inputs.qt_version == '6' && format('macOS_{0}_qt6', matrix.architecture) || format('macOS_{0}', matrix.architecture) }} ###################### ###### Windows ####### @@ -148,41 +155,40 @@ jobs: name: 🪟 Windows x64 runs-on: windows-2022 env: - VCINSTALLDIR: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC' + LIBJPEG_TURBO_VERSION: 3.0.1 steps: - name: ⬇ Checkout uses: actions/checkout@v4 with: submodules: recursive - - name: 🔧 Prepare PR + - name: 🔧 Append Pull Request number to version (PR only) if: ${{ inputs.event_name == 'pull_request' }} shell: bash - run: | - echo '::group::Append PR number to version' - tr -d '\n' < .version > temp && mv temp .version - echo -n "+PR${{ inputs.pull_request_number }}" >> .version - echo '::endgroup::' + run: tr -d '\n' < .version > temp && mv temp .version && echo -n "+PR${{ inputs.pull_request_number }}" >> .version - - name: 💾 Cache/Restore - uses: actions/cache@v4 + - name: 💾 Restore DirectX SDK (if available) + uses: ethanjli/cached-download-action@v0.1.2 with: - path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey - key: ${{ runner.os }}${{ '-chocolatey' }} + url: https://download.microsoft.com/download/A/E/7/AE743F1F-632B-4809-87A9-AA1BB3458E31/DXSDK_Jun10.exe + destination: .\installer\dxsdk-jun10.exe + cache-key: dxsdk-jun10 - - name: 📥 Install DirectX SDK, OpenSSL, libjpeg-turbo - shell: powershell + - name: 💾 Restore libjpeg-turbo (if available) + uses: ethanjli/cached-download-action@v0.1.2 + with: + url: https://sourceforge.net/projects/libjpeg-turbo/files/${{ env.LIBJPEG_TURBO_VERSION }}/libjpeg-turbo-${{ env.LIBJPEG_TURBO_VERSION }}-vc64.exe + destination: .\installer\libjpeg-turbo.exe + cache-key: libjpeg-turbo + + - name: 📥 Install DirectX SDK & libjpeg-turbo run: | - choco install --no-progress directx-sdk -y - choco install --no-progress ${{env.OPENSSL}} -y - Invoke-WebRequest https://netcologne.dl.sourceforge.net/project/libjpeg-turbo/3.0.1/libjpeg-turbo-3.0.1-vc64.exe -OutFile libjpeg-turbo.exe -UserAgent NativeHost - .\libjpeg-turbo /S - env: - OPENSSL: ${{ inputs.qt_version == '6' && 'openssl' || 'openssl --version=1.1.1.2100' }} + cmd.exe /c start /wait .\installer\libjpeg-turbo.exe /S + cmd.exe /c start /wait .\installer\dxsdk-jun10.exe /U /F - - name: Install Vulkan SDK + - name: 📥 Install Vulkan SDK if: ${{ inputs.qt_version == '6' }} - uses: jakoch/install-vulkan-sdk-action@v1.1.1 + uses: jakoch/install-vulkan-sdk-action@v1 with: install_runtime: false cache: true @@ -198,19 +204,15 @@ jobs: cache-key-prefix: 'cache-qt-windows' - name: 🛠️ Setup MSVC - shell: cmd - run: call "${{env.VCINSTALLDIR}}\Auxiliary\Build\vcvars64.bat" - - - name: Temporarily downgrade CMake to 3.28.3 # Please remove if GitHub has updated Cmake (greater than 3.30.0) - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '3.28.3' + uses: ilammy/msvc-dev-cmd@v1 - name: 👷 Build - shell: bash - run: ./.github/scripts/build.sh + shell: cmd + run: | + cmake --preset windows-${{ env.BUILD_TYPE }} + cmake --build --preset windows-${{ env.BUILD_TYPE }} --target package --parallel %NUMBER_OF_PROCESSORS% env: - PLATFORM: windows + BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }} - name: 📦 Upload if: ${{ inputs.publish || inputs.event_name == 'pull_request' }} @@ -236,13 +238,11 @@ jobs: - name: 🔧 Prepare run: | - echo '::group::Generate environment variables from .version and tag' - echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - echo "VERSION=$(tr -d '\n' < .version)" >> $GITHUB_ENV - echo '::endgroup::' + echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + echo "VERSION=$(tr -d '\n' < .version)" >> $GITHUB_ENV - name: 💾 Artifact download - uses: actions/download-artifact@v4.1.9 + uses: actions/download-artifact@v4 with: pattern: artifact-* path: all-artifacts diff --git a/CMakeLists.txt b/CMakeLists.txt index af7b746e1..5c3c100c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,68 +1,100 @@ -cmake_minimum_required(VERSION 3.5.0) +#============================================================================= +# Minimum required CMake version is 3.5.0 +#============================================================================= +cmake_minimum_required(VERSION 3.5.0) message(STATUS "CMake Version: ${CMAKE_VERSION}") -macro(addIndent text) - if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") - list(APPEND CMAKE_MESSAGE_INDENT ${text}) - endif() -endmacro() +#============================================================================= +# CMake policies +#============================================================================= -macro(removeIndent) - if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") - list(POP_BACK CMAKE_MESSAGE_INDENT) - endif() -endmacro() +# Disable passing /W3 by default on MSVC +if(POLICY CMP0092) + cmake_policy(SET CMP0092 NEW) +endif() -PROJECT(hyperion) +#============================================================================= +# Our main project :) +#============================================================================= -# Parse semantic version of version file and write version to config -include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake) -file (STRINGS ".version" HYPERION_VERSION) -SetVersionNumber(HYPERION ${HYPERION_VERSION}) -set(DEFAULT_JSON_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/settings/hyperion.settings.json.default) -file(READ ${DEFAULT_JSON_CONFIG_FILE} DEFAULT_JSON_CONFIG_VAR) -string(REPLACE "configVersionValue" ${HYPERION_VERSION} DEFAULT_JSON_CONFIG_VAR "${DEFAULT_JSON_CONFIG_VAR}") -file(WRITE ${CMAKE_BINARY_DIR}/settings/hyperion.settings.json.default "${DEFAULT_JSON_CONFIG_VAR}") +project(hyperion) + +#============================================================================= +# Set the required Cxx standard +#============================================================================= + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +#============================================================================= +# Instruct CMake to run moc automatically when needed and auto prepare .qrc files +#============================================================================= -# Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -# auto prepare .qrc files set(CMAKE_AUTORCC ON) -# multicore compiling -include(ProcessorCount) -ProcessorCount(NCORES) -if(NOT NCORES EQUAL 0) - set(CMAKE_BUILD_PARALLEL_LEVEL NCORES) +#============================================================================= +# Append our cmake module path (for include, find, etc.) +# Include the helper macros/functions +#============================================================================= + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(HelperMacros) +include(HelperFunctions) + +#============================================================================= +# Use ccache as compiler launcher +#============================================================================= + +# Configure CCache if available +find_program(CACHE_PROG ccache) +if(CACHE_PROG) +message(STATUS "Building with ccache: ${CACHE_PROG}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CACHE_PROG}) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CACHE_PROG}) endif() -# Configure CCache ifavailable -find_program(CCACHE_FOUND ccache) -if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) -endif(CCACHE_FOUND) +#============================================================================= +# Set output directories and add the project/dependencies include directory +#============================================================================= -# enable C++17 -if(APPLE) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("Werror=unguarded-availability" REQUIRED_UNGUARDED_AVAILABILITY) - if(REQUIRED_UNGUARDED_AVAILABILITY) - list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "Werror=unguarded-availability") - endif() -endif() +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi") +if(MSVC) + foreach(CONFIG_TYPE "RELEASE" "DEBUG" "RELWITHDEBINFO" "MINSIZEREL") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) + endforeach() endif() -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +include_directories(${CMAKE_SOURCE_DIR}/dependencies/include) +include_directories(${CMAKE_SOURCE_DIR}/include) + +#============================================================================= +# Parse semantic version of version file and write version to config +# Determine branch name and build id +#============================================================================= +file (STRINGS ".version" HYPERION_VERSION) +SetVersionNumber(HYPERION ${HYPERION_VERSION}) +set(DEFAULT_JSON_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/settings/hyperion.settings.json.default) +file(READ ${DEFAULT_JSON_CONFIG_FILE} DEFAULT_JSON_CONFIG_VAR) +string(REPLACE "configVersionValue" ${HYPERION_VERSION} DEFAULT_JSON_CONFIG_VAR "${DEFAULT_JSON_CONFIG_VAR}") +file(WRITE ${CMAKE_BINARY_DIR}/settings/hyperion.settings.json.default "${DEFAULT_JSON_CONFIG_VAR}") + +include(GitVersion) +message(STATUS "Current Version: ${HYPERION_VERSION}") +message(STATUS " - Build: ${HYPERION_BUILD_ID}") + +#============================================================================= # Set build variables +#============================================================================= + # Grabber set(DEFAULT_AMLOGIC OFF) set(DEFAULT_DISPMANX OFF) @@ -122,7 +154,7 @@ if(${CMAKE_SYSTEM} MATCHES "Linux") set(DEFAULT_CEC ON) elseif (WIN32) set(DEFAULT_DX ON ) - set(DEFAULT_DDA ON ) + set(DEFAULT_DDA ON ) set(DEFAULT_MF ON ) set(DEFAULT_DEV_FTDI OFF) else() @@ -134,45 +166,20 @@ else() set(DEFAULT_CEC OFF) endif() +#============================================================================= +# Determine/Evaluate the current platform +#============================================================================= + if(NOT DEFINED PLATFORM) - if(APPLE) - set(PLATFORM "osx") - elseif (WIN32) - set(PLATFORM "windows") - elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86") - set(PLATFORM "x11") - elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") - set(PLATFORM "rpi") - file(READ /proc/cpuinfo SYSTEM_CPUINFO) - STRING (TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO) - if("${SYSTEM_CPUINFO}" MATCHES "amlogic" AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4) - set(PLATFORM "amlogic") - elseif (("${SYSTEM_CPUINFO}" MATCHES "amlogic" OR "${SYSTEM_CPUINFO}" MATCHES "odroid-c2" OR "${SYSTEM_CPUINFO}" MATCHES "vero4k") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(PLATFORM "amlogic64") - endif() - endif() - if(PLATFORM) - message(STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}") - else() - message(FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=") + set(PLATFORM) + DeterminePlatform(PLATFORM) + if(NOT PLATFORM) + message(FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=") endif() +else() + message(STATUS "PLATFORM: ${PLATFORM}") endif() -message(STATUS "PLATFORM: ${PLATFORM}") - -# Macro to get path of first sub dir of a dir, used for MAC OSX lib/header searching -macro(FIRSTSUBDIR result curdir) - file(GLOB children RELATIVE ${curdir} ${curdir}/*) - set(dirlist "") - foreach(child ${children}) - if(IS_DIRECTORY ${curdir}/${child}) - list(APPEND dirlist "${curdir}/${child}") - break() - endif() - endforeach() - set(${result} ${dirlist}) -endmacro() - if("${PLATFORM}" MATCHES "osx") # specify the min version of the target platform (only GitHub Actions) if(DEFINED ENV{GITHUB_WORKSPACE}) @@ -219,7 +226,9 @@ string(TOUPPER "-DPLATFORM_${PLATFORM}" PLATFORM_DEFINE) string(REPLACE "-DEV" "" PLATFORM_DEFINE "${PLATFORM_DEFINE}") ADD_DEFINITIONS(${PLATFORM_DEFINE}) -# set the build options +#============================================================================= +# Set the build options +#============================================================================= option(HYPERION_LIGHT "Build Hyperion with a reduced set of functionality" ${DEFAULT_HYPERION_LIGHT}) message(STATUS "HYPERION_LIGHT = ${HYPERION_LIGHT}") @@ -423,21 +432,31 @@ message(STATUS "ENABLE_TESTS = ${ENABLE_TESTS}") removeIndent() -set(FLATBUFFERS_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/flatbuf) -set(FLATBUFFERS_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/flatbuf) +#============================================================================= +# Configure the predefined header file to pass selected options to the code +#============================================================================= -set(PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto) -set(PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto) +configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h") +include_directories(${PROJECT_BINARY_DIR}) + +# Setup header file cleanup job +if(NOT CMAKE_VERSION VERSION_LESS "3.15") + set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_BINARY_DIR}/HyperionConfig.h) +else() + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/HyperionConfig.h) +endif() + +#============================================================================= +# Check JSON files/schemas +#============================================================================= if(ENABLE_JSONCHECKS OR ENABLE_EFFECTENGINE) - if("${CMAKE_VERSION}" VERSION_LESS "3.12.0") - set(Python_ADDITIONAL_VERSIONS 3.5) - find_package(PythonInterp 3.5 REQUIRED) + if(CMAKE_VERSION VERSION_LESS "3.12") + set(Python_ADDITIONAL_VERSIONS 3.5) + find_package(PythonInterp 3.5 REQUIRED) else() - find_package(Python3 3.5 COMPONENTS Interpreter Development REQUIRED) - if(Python3_FOUND) - set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) - endif() + find_package(Python3 3.5 REQUIRED) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) endif() endif() @@ -451,6 +470,7 @@ if(ENABLE_JSONCHECKS) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE CHECK_JSON_FAILED ) + if(${CHECK_JSON_FAILED}) message (FATAL_ERROR "check of json files failed") endif() @@ -475,47 +495,29 @@ if(ENABLE_JSONCHECKS) if(${CHECK_CONFIG_FAILED}) message (FATAL_ERROR "check of json default config failed") endif() -endif(ENABLE_JSONCHECKS) - -# Add project specific cmake modules (find, etc) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -find_package(GitVersion) - -# configure a header file to pass some of the CMake settings -# to the source code -configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h") -include_directories("${PROJECT_BINARY_DIR}") - -# Define the global output path of binaries -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) - -file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) -file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - -# Add the project include directory as additional include path -include_directories(${CMAKE_SOURCE_DIR}/dependencies/include) -include_directories(${CMAKE_SOURCE_DIR}/include) +endif() -# Prefer static linking over dynamic -#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") +#============================================================================= +# Platform-specific tasks +#============================================================================= -# MSVC options -if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - # Search for Windows SDK +# Search for Windows SDK +if(MSVC) find_package(WindowsSDK REQUIRED) message(STATUS "WINDOWS SDK: ${WINDOWSSDK_LATEST_DIR} ${WINDOWSSDK_LATEST_NAME}") message(STATUS "MSVC VERSION: ${MSVC_VERSION}") endif() -# Don't create new dynamic tags (RUNPATH) and setup -rpath to search for shared libs in BINARY/../lib folder (only for Unix) -if(ENABLE_DEPLOY_DEPENDENCIES AND UNIX AND NOT APPLE) +# If Hyperion is deployed with all dependencies under Linux +# it is necessary to deactivate the linker option dtag +if(ENABLE_DEPLOY_DEPENDENCIES AND SYSTEM_MATCHES_LINUX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--disable-new-dtags") - set(CMAKE_SKIP_BUILD_RPATH FALSE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--disable-new-dtags") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--disable-new-dtags") + set(CMAKE_SKIP_BUILD_RPATH OFF) + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) endif() if(APPLE) @@ -523,15 +525,19 @@ if(APPLE) endif() find_package(Threads REQUIRED) +find_package(libusb-1.0 REQUIRED) +#============================================================================= # Allow to overwrite QT base directory # Either supply QTDIR as -DQTDIR= to cmake or set and environment variable QTDIR pointing to the Qt installation -# For Windows and OSX, the default Qt installation path are tried to resolved automatically +# For Windows and macOS, the default Qt installation path are tried to resolved automatically +#============================================================================= + if(NOT DEFINED QTDIR) if(DEFINED ENV{QTDIR}) set(QTDIR $ENV{QTDIR}) else() - if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + if(MSVC) FIRSTSUBDIR(SUBDIRQT "C:/Qt") if(NOT ${SUBDIRQT} STREQUAL "") set(QTDIR "${SUBDIRQT}/msvc2019_64") @@ -556,7 +562,10 @@ endif() if(DEFINED QTDIR) message(STATUS "Add QTDIR: ${QTDIR} to CMAKE_PREFIX_PATH") - list(PREPEND CMAKE_PREFIX_PATH ${QTDIR} "${QTDIR}/lib") + list(PREPEND CMAKE_PREFIX_PATH + ${QTDIR} + ${QTDIR}/lib + ) endif() if(CMAKE_PREFIX_PATH) @@ -585,38 +594,30 @@ if(APPLE AND (${QT_VERSION_MAJOR} GREATER_EQUAL 6)) set(OPENSSL_ROOT_DIR /usr/local/opt/openssl) endif() -# Add libusb and pthreads -find_package(libusb-1.0 REQUIRED) -add_definitions(${QT_DEFINITIONS}) +#============================================================================= +# Add our Code +#============================================================================= # Add the source/lib directories add_subdirectory(dependencies) +add_subdirectory(resources) add_subdirectory(libsrc) add_subdirectory(src) if(ENABLE_TESTS) add_subdirectory(test) endif() -# Add resources directory -add_subdirectory(resources) - -# remove generated files on make cleaan too -list(APPEND GENERATED_QRC - ${CMAKE_BINARY_DIR}/WebConfig.qrc - ${CMAKE_BINARY_DIR}/HyperionConfig.h -) +#============================================================================= +# Create uninstall target +#============================================================================= -if(ENABLE_EFFECTENGINE) -list(APPEND GENERATED_QRC - ${CMAKE_BINARY_DIR}/EffectEngine.qrc +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake ) -endif() -set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_QRC}") - -# uninstall target -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) -add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +#============================================================================= +# Add Packaging +#============================================================================= -# enable make package - no code after this line ! -include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/packages.cmake) +include(Packaging) diff --git a/CMakePresets.json b/CMakePresets.json index 1f0dc222d..8d6ed51f2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -110,9 +110,11 @@ { "name": "msvc", "hidden": true, - "generator": "Visual Studio 17 2022", - "architecture": "x64", - "toolset": "host=x64" + "generator": "Ninja", + "cacheVariables": { + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe" + } }, { "name": "gcc", @@ -167,7 +169,7 @@ "name": "windows-release", "displayName": "Windows Release (msvc)", "description": "Build with MSVC's CL as Release without Debug Symbols", - "inherits": [ "base", "msvc" ], + "inherits": [ "base", "release", "msvc" ], "condition": { "type": "equals", "lhs": "${hostSystemName}", @@ -178,7 +180,7 @@ "name": "windows-debug", "displayName": "Windows Debug (msvc)", "description": "Build with MSVC's CL with Debug Symbols", - "inherits": [ "base", "msvc" ], + "inherits": [ "base", "debug", "msvc" ], "condition": { "type": "equals", "lhs": "${hostSystemName}", diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake deleted file mode 100644 index 01142373e..000000000 --- a/cmake/Dependencies.cmake +++ /dev/null @@ -1,537 +0,0 @@ -macro(DeployMacOS TARGET) - if (EXISTS ${TARGET_FILE}) - message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}") - - get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) - execute_process( - COMMAND ${QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS - OUTPUT_VARIABLE QT_PLUGIN_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - install(CODE "set(TARGET_FILE \"${TARGET_FILE}\")" COMPONENT "Hyperion") - install(CODE "set(TARGET_BUNDLE_NAME \"${TARGET}.app\")" COMPONENT "Hyperion") - install(CODE "set(PLUGIN_DIR \"${QT_PLUGIN_DIR}\")" COMPONENT "Hyperion") - install(CODE "set(ENABLE_EFFECTENGINE \"${ENABLE_EFFECTENGINE}\")" COMPONENT "Hyperion") - - install(CODE [[ - - set(BUNDLE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}") - - file(GET_RUNTIME_DEPENDENCIES - EXECUTABLES ${TARGET_FILE} - RESOLVED_DEPENDENCIES_VAR resolved_deps - UNRESOLVED_DEPENDENCIES_VAR unresolved_deps - ) - - foreach(dependency ${resolved_deps}) - string(FIND ${dependency} "dylib" _index) - if (${_index} GREATER -1) - file(INSTALL - FILES "${dependency}" - DESTINATION "${BUNDLE_INSTALL_DIR}/Contents/Frameworks" - TYPE SHARED_LIBRARY - ) - else() - file(INSTALL - FILES "${dependency}" - DESTINATION "${BUNDLE_INSTALL_DIR}/Contents/lib" - TYPE SHARED_LIBRARY - FOLLOW_SYMLINK_CHAIN - ) - endif() - endforeach() - - list(LENGTH unresolved_deps unresolved_length) - if("${unresolved_length}" GREATER 0) - MESSAGE("The following unresolved dependencies were discovered: ${unresolved_deps}") - endif() - - foreach(PLUGIN "platforms" "sqldrivers" "imageformats" "tls") - if(EXISTS ${PLUGIN_DIR}/${PLUGIN}) - file(GLOB files "${PLUGIN_DIR}/${PLUGIN}/*") - foreach(file ${files}) - file(GET_RUNTIME_DEPENDENCIES - EXECUTABLES ${file} - RESOLVED_DEPENDENCIES_VAR PLUGINS - UNRESOLVED_DEPENDENCIES_VAR unresolved_deps - ) - - foreach(DEPENDENCY ${PLUGINS}) - file(INSTALL - DESTINATION "${BUNDLE_INSTALL_DIR}/Contents/lib" - TYPE SHARED_LIBRARY - FILES ${DEPENDENCY} - FOLLOW_SYMLINK_CHAIN - ) - endforeach() - - get_filename_component(singleQtLib ${file} NAME) - list(APPEND QT_PLUGINS "${BUNDLE_INSTALL_DIR}/Contents/plugins/${PLUGIN}/${singleQtLib}") - file(INSTALL - FILES ${file} - DESTINATION "${BUNDLE_INSTALL_DIR}/Contents/plugins/${PLUGIN}" - TYPE SHARED_LIBRARY - ) - - endforeach() - endif() - endforeach() - - include(BundleUtilities) - fixup_bundle("${BUNDLE_INSTALL_DIR}" "${QT_PLUGINS}" "${BUNDLE_INSTALL_DIR}/Contents/lib" IGNORE_ITEM "python;python3;Python;Python3;.Python;.Python3") - file(REMOVE_RECURSE "${BUNDLE_INSTALL_DIR}/Contents/lib") - - if(ENABLE_EFFECTENGINE) - # Detect the Python version and modules directory - if(NOT CMAKE_VERSION VERSION_LESS "3.12") - find_package(Python3 COMPONENTS Interpreter Development REQUIRED) - set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") - set(PYTHON_MODULES_DIR ${Python3_STDLIB}) - else() - find_package (PythonLibs ${PYTHON_VERSION_STRING} EXACT) - set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") - set(PYTHON_MODULES_DIR ${Python_STDLIB}) - endif() - - MESSAGE("Add Python ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} to bundle") - MESSAGE("PYTHON_MODULES_DIR: ${PYTHON_MODULES_DIR}") - - # Copy Python modules to '/../Frameworks/Python.framework/Versions/Current/lib/PythonMAJOR.MINOR' and ignore the unnecessary stuff listed below - if (PYTHON_MODULES_DIR) - set(PYTHON_FRAMEWORK "${BUNDLE_INSTALL_DIR}/Contents/Frameworks/Python.framework") - file( - COPY ${PYTHON_MODULES_DIR}/ - DESTINATION "${PYTHON_FRAMEWORK}/Versions/Current/lib/python${PYTHON_VERSION_MAJOR_MINOR}" - PATTERN "*.pyc" EXCLUDE # compiled bytecodes - PATTERN "__pycache__" EXCLUDE # any cache - PATTERN "config-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}*" EXCLUDE # static libs - PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation - PATTERN "tkinter" EXCLUDE # Tk interface - PATTERN "lib-dynload/_tkinter.*" EXCLUDE - PATTERN "idlelib" EXCLUDE - PATTERN "turtle.py" EXCLUDE # Tk demo - PATTERN "test" EXCLUDE # unittest module - PATTERN "sitecustomize.py" EXCLUDE # site-specific configs - ) - endif(PYTHON_MODULES_DIR) - endif(ENABLE_EFFECTENGINE) - - file(GLOB_RECURSE LIBS FOLLOW_SYMLINKS "${BUNDLE_INSTALL_DIR}/*.dylib") - file(GLOB FRAMEWORKS FOLLOW_SYMLINKS LIST_DIRECTORIES ON "${BUNDLE_INSTALL_DIR}/Contents/Frameworks/*") - foreach(item ${LIBS} ${FRAMEWORKS} ${PYTHON_FRAMEWORK} ${BUNDLE_INSTALL_DIR}) - set(cmd codesign --deep --force --sign - "${item}") - execute_process( - COMMAND ${cmd} - RESULT_VARIABLE codesign_result - ) - - if(NOT codesign_result EQUAL 0) - message(WARNING "macOS signing failed; ${cmd} returned ${codesign_result}") - endif() - endforeach() - - ]] COMPONENT "Hyperion") - - else() - add_custom_command( - TARGET ${TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$" - ARGS ${CMAKE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - VERBATIM - ) - endif() -endmacro() - -macro(DeployLinux TARGET) - if (EXISTS ${TARGET_FILE}) - message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}") - include(GetPrerequisites) - - set(SYSTEM_LIBS_SKIP - "libatomic" - "libc" - "libdbus" - "libdl" - "libexpat" - "libfontconfig" - "libgcc_s" - "libgcrypt" - "libglib" - "libglib-2" - "libgpg-error" - "liblz4" - "liblzma" - "libm" - "libpcre" - "libpcre2" - "libpthread" - "librt" - "libstdc++" - "libsystemd" - "libudev" - "libusb" - "libusb-1" - "libutil" - "libuuid" - "libz" - ) - - if (ENABLE_DISPMANX) - list(APPEND SYSTEM_LIBS_SKIP "libcec") - endif() - - # Extract dependencies ignoring the system ones - get_prerequisites(${TARGET_FILE} DEPENDENCIES 0 1 "" "") - - message(STATUS "Dependencies for target file: ${DEPENDENCIES}") - - # Append symlink and non-symlink dependencies to the list - set(PREREQUISITE_LIBS "") - foreach(DEPENDENCY ${DEPENDENCIES}) - get_filename_component(resolved ${DEPENDENCY} NAME_WE) - list(FIND SYSTEM_LIBS_SKIP ${resolved} _index) - - if (${_index} GREATER -1) - continue() # Skip system libraries - else() - gp_resolve_item("${TARGET_FILE}" "${DEPENDENCY}" "" "" resolved_file) - get_filename_component(resolved_file ${resolved_file} ABSOLUTE) - gp_append_unique(PREREQUISITE_LIBS ${resolved_file}) - get_filename_component(file_canonical ${resolved_file} REALPATH) - gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) - endif() - endforeach() - - # Append the OpenSSL library to the list - find_package(OpenSSL 1.0.0 REQUIRED) - if (OPENSSL_FOUND) - foreach(openssl_lib ${OPENSSL_LIBRARIES}) - get_prerequisites(${openssl_lib} openssl_deps 0 1 "" "") - - foreach(openssl_dep ${openssl_deps}) - get_filename_component(resolved ${openssl_dep} NAME_WE) - list(FIND SYSTEM_LIBS_SKIP ${resolved} _index) - if (${_index} GREATER -1) - continue() # Skip system libraries - else() - gp_resolve_item("${openssl_lib}" "${openssl_dep}" "" "" resolved_file) - get_filename_component(resolved_file ${resolved_file} ABSOLUTE) - gp_append_unique(PREREQUISITE_LIBS ${resolved_file}) - get_filename_component(file_canonical ${resolved_file} REALPATH) - gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) - endif() - endforeach() - - gp_append_unique(PREREQUISITE_LIBS ${openssl_lib}) - get_filename_component(file_canonical ${openssl_lib} REALPATH) - gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) - endforeach() - else() - message( WARNING "OpenSSL NOT found (https webserver will not work)") - endif(OPENSSL_FOUND) - - # Detect the Qt plugin directory, source: https://github.com/lxde/lxqt-qtplugin/blob/master/src/CMakeLists.txt - if ( TARGET Qt${QT_VERSION_MAJOR}::qmake ) - get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) - execute_process( - COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS - OUTPUT_VARIABLE QT_PLUGINS_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() - - # Copy Qt plugins to 'share/hyperion/lib' - if (QT_PLUGINS_DIR) - foreach(PLUGIN "platforms" "sqldrivers" "imageformats" "tls" "wayland-shell-integration") - if (EXISTS ${QT_PLUGINS_DIR}/${PLUGIN}) - file(GLOB files "${QT_PLUGINS_DIR}/${PLUGIN}/*.so") - foreach(file ${files}) - get_prerequisites(${file} PLUGINS 0 1 "" "") - foreach(DEPENDENCY ${PLUGINS}) - get_filename_component(resolved ${DEPENDENCY} NAME_WE) - list(FIND SYSTEM_LIBS_SKIP ${resolved} _index) - if (${_index} GREATER -1) - continue() # Skip system libraries - else() - gp_resolve_item("${file}" "${DEPENDENCY}" "" "" resolved_file) - get_filename_component(resolved_file ${resolved_file} ABSOLUTE) - gp_append_unique(PREREQUISITE_LIBS ${resolved_file}) - get_filename_component(file_canonical ${resolved_file} REALPATH) - gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) - endif() - endforeach() - - install( - FILES ${file} - DESTINATION "share/hyperion/lib/${PLUGIN}" - COMPONENT "Hyperion" - ) - endforeach() - endif() - endforeach() - endif(QT_PLUGINS_DIR) - - # Create a qt.conf file in 'share/hyperion/bin' to override hard-coded search paths in Qt plugins - file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n") - install( - FILES "${CMAKE_BINARY_DIR}/qt.conf" - DESTINATION "share/hyperion/bin" - COMPONENT "Hyperion" - ) - - # Copy dependencies to 'share/hyperion/lib' - foreach(PREREQUISITE_LIB ${PREREQUISITE_LIBS}) - install( - FILES ${PREREQUISITE_LIB} - DESTINATION "share/hyperion/lib" - COMPONENT "Hyperion" - ) - endforeach() - - if(ENABLE_EFFECTENGINE) - # Detect the Python version and modules directory - if (NOT CMAKE_VERSION VERSION_LESS "3.12") - find_package(Python3 COMPONENTS Interpreter Development REQUIRED) - set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") - set(PYTHON_MODULES_DIR ${Python3_STDLIB}) - else() - find_package (PythonLibs ${PYTHON_VERSION_STRING} EXACT) - set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") - set(PYTHON_MODULES_DIR ${Python_STDLIB}) - endif() - - # Copy Python modules to 'share/hyperion/lib/pythonMAJOR.MINOR' and ignore the unnecessary stuff listed below - if (PYTHON_MODULES_DIR) - - install( - DIRECTORY ${PYTHON_MODULES_DIR}/ - DESTINATION "share/hyperion/lib/python${PYTHON_VERSION_MAJOR_MINOR}" - COMPONENT "Hyperion" - PATTERN "*.pyc" EXCLUDE # compiled bytecodes - PATTERN "__pycache__" EXCLUDE # any cache - PATTERN "config-${PYTHON_VERSION_MAJOR_MINOR}*" EXCLUDE # static libs - PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation - PATTERN "tkinter" EXCLUDE # Tk interface - PATTERN "turtle.py" EXCLUDE # Tk demo - PATTERN "test" EXCLUDE # unittest module - PATTERN "sitecustomize.py" EXCLUDE # site-specific configs - ) - endif(PYTHON_MODULES_DIR) - endif(ENABLE_EFFECTENGINE) - - else() - # Run CMake after target was built to run get_prerequisites on ${TARGET_FILE} - add_custom_command( - TARGET ${TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$" - ARGS ${CMAKE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - VERBATIM - ) - endif() -endmacro() - -macro(DeployWindows TARGET) - if (EXISTS ${TARGET_FILE}) - message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}") - find_package(Qt${QT_VERSION_MAJOR}Core REQUIRED) - find_package(OpenSSL REQUIRED) - - # Find the windeployqt binaries - get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) - get_filename_component(QT_BIN_DIR "${QMAKE_EXECUTABLE}" DIRECTORY) - find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}") - - # Collect the runtime libraries - get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" DIRECTORY) - if (QT_VERSION_MAJOR EQUAL 5) - set(WINDEPLOYQT_PARAMS --no-angle --no-opengl-sw) - else() - set(WINDEPLOYQT_PARAMS --no-opengl-sw) - endif() - - execute_process( - COMMAND "${CMAKE_COMMAND}" -E - env "PATH=${COMPILER_PATH};${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}" - --dry-run - ${WINDEPLOYQT_PARAMS} - --list mapping - "${TARGET_FILE}" - OUTPUT_VARIABLE DEPS - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - # Parse DEPS into a semicolon-separated list. - separate_arguments(DEPENDENCIES WINDOWS_COMMAND ${DEPS}) - string(REPLACE "\\" "/" DEPENDENCIES "${DEPENDENCIES}") - - # Copy dependencies to 'hyperion/lib' or 'hyperion' - while (DEPENDENCIES) - list(GET DEPENDENCIES 0 src) - list(GET DEPENDENCIES 1 dst) - get_filename_component(dst ${dst} DIRECTORY) - - if (NOT "${dst}" STREQUAL "") - install( - FILES ${src} - DESTINATION "lib/${dst}" - COMPONENT "Hyperion" - ) - else() - install( - FILES ${src} - DESTINATION "bin" - COMPONENT "Hyperion" - ) - endif() - - list(REMOVE_AT DEPENDENCIES 0 1) - endwhile() - - # Copy libssl/libcrypto to 'hyperion' - if (OPENSSL_FOUND) - string(REGEX MATCHALL "[0-9]+" openssl_versions "${OPENSSL_VERSION}") - list(GET openssl_versions 0 openssl_version_major) - list(GET openssl_versions 1 openssl_version_minor) - - set(open_ssl_version_suffix) - if (openssl_version_major VERSION_EQUAL 1 AND openssl_version_minor VERSION_EQUAL 1) - set(open_ssl_version_suffix "-1_1") - else() - set(open_ssl_version_suffix "-3") - endif() - - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - string(APPEND open_ssl_version_suffix "-x64") - endif() - - find_file(OPENSSL_SSL - NAMES "libssl${open_ssl_version_suffix}.dll" - PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin - NO_DEFAULT_PATH - ) - - find_file(OPENSSL_CRYPTO - NAMES "libcrypto${open_ssl_version_suffix}.dll" - PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin - NO_DEFAULT_PATH - ) - - install( - FILES ${OPENSSL_SSL} ${OPENSSL_CRYPTO} - DESTINATION "bin" - COMPONENT "Hyperion" - ) - endif(OPENSSL_FOUND) - - # Copy libjpeg-turbo to 'hyperion' - if (ENABLE_MF) - find_package(TurboJPEG) - - if (TURBOJPEG_FOUND) - find_file(TURBOJPEG_DLL - NAMES "turbojpeg.dll" - PATHS ${TurboJPEG_INCLUDE_DIRS}/.. ${TurboJPEG_INCLUDE_DIRS}/../bin - NO_DEFAULT_PATH - ) - - find_file(JPEG_DLL - NAMES "jpeg62.dll" - PATHS ${TurboJPEG_INCLUDE_DIRS}/.. ${TurboJPEG_INCLUDE_DIRS}/../bin - NO_DEFAULT_PATH - ) - - install( - FILES ${TURBOJPEG_DLL} ${JPEG_DLL} - DESTINATION "bin" - COMPONENT "Hyperion" - ) - endif(TURBOJPEG_FOUND) - endif(ENABLE_MF) - - # Create a qt.conf file in 'bin' to override hard-coded search paths in Qt plugins - file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n") - install( - FILES "${CMAKE_BINARY_DIR}/qt.conf" - DESTINATION "bin" - COMPONENT "Hyperion" - ) - - if(ENABLE_EFFECTENGINE) - # Download embed python package (only release build package available) - # Currently only cmake version >= 3.12 implemented - set(url "https://www.python.org/ftp/python/${Python3_VERSION}/") - set(filename "python-${Python3_VERSION}-embed-amd64.zip") - - if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${filename}" OR NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/python") - file(DOWNLOAD "${url}${filename}" "${CMAKE_CURRENT_BINARY_DIR}/${filename}" - STATUS result - ) - - # Check if the download is successful - list(GET result 0 result_code) - if(NOT result_code EQUAL 0) - list(GET result 1 reason) - message(FATAL_ERROR "Could not download file ${url}${filename}: ${reason}") - endif() - - # Unpack downloaded embed python - file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/python) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python) - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar -xfz "${CMAKE_CURRENT_BINARY_DIR}/${filename}" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python - OUTPUT_QUIET - ) - endif() - - # Copy pythonXX.dll and pythonXX.zip to 'hyperion' - foreach(PYTHON_FILE - "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.dll" - "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.zip" - ) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_FILE} - DESTINATION "bin" - COMPONENT "Hyperion" - ) - endforeach() - endif(ENABLE_EFFECTENGINE) - - if (ENABLE_DX) - # Download DirectX End-User Runtimes (June 2010) - set(url "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe") - if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe") - file(DOWNLOAD "${url}" "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe" - STATUS result - ) - - # Check if the download is successful - list(GET result 0 result_code) - if (NOT result_code EQUAL 0) - list(GET result 1 reason) - message(FATAL_ERROR "Could not download DirectX End-User Runtimes: ${reason}") - endif() - endif() - - # Copy DirectX End-User Runtimes to 'hyperion' - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe - DESTINATION "bin" - COMPONENT "Hyperion" - ) - endif (ENABLE_DX) - - else() - # Run CMake after target was built - add_custom_command( - TARGET ${TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$" - ARGS ${CMAKE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - VERBATIM - ) - endif() -endmacro() diff --git a/cmake/FindGitVersion.cmake b/cmake/FindGitVersion.cmake deleted file mode 100644 index 6c0597ff4..000000000 --- a/cmake/FindGitVersion.cmake +++ /dev/null @@ -1,12 +0,0 @@ -execute_process( COMMAND git config --global --add safe.directory "*" ERROR_QUIET ) -execute_process( COMMAND git log -1 --format=%cn-%t/%h-%ct WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE BUILD_ID ERROR_QUIET ) -execute_process( COMMAND sh -c "git branch | grep '^*' | sed 's;^*;;g' " WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_ID ERROR_QUIET ) -execute_process( COMMAND sh -c "git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_REMOTE_PATH ERROR_QUIET ) - -STRING ( STRIP "${BUILD_ID}" BUILD_ID ) -STRING ( STRIP "${VERSION_ID}" VERSION_ID ) -STRING ( STRIP "${GIT_REMOTE_PATH}" GIT_REMOTE_PATH ) -SET ( HYPERION_BUILD_ID "${VERSION_ID} (${BUILD_ID})" ) -SET ( HYPERION_GIT_REMOTE "${GIT_REMOTE_PATH}" ) -message ( STATUS "Current Version: ${HYPERION_VERSION}" ) -message ( STATUS " - Build: ${HYPERION_BUILD_ID}" ) diff --git a/cmake/FindTurboJPEG.cmake b/cmake/FindTurboJPEG.cmake index 37900e8ac..849798e5f 100644 --- a/cmake/FindTurboJPEG.cmake +++ b/cmake/FindTurboJPEG.cmake @@ -1,49 +1,42 @@ # FindTurboJPEG.cmake # TURBOJPEG_FOUND -# TurboJPEG_INCLUDE_DIRS +# TurboJPEG_INCLUDE_DIR # TurboJPEG_LIBRARY -if (ENABLE_MF) - find_path(TurboJPEG_INCLUDE_DIRS - NAMES turbojpeg.h - PATHS +find_path(TurboJPEG_INCLUDE_DIR + NAMES + turbojpeg.h + PATHS "C:/libjpeg-turbo64" - PATH_SUFFIXES include - ) + PATH_SUFFIXES + include +) - find_library(TurboJPEG_LIBRARY - NAMES turbojpeg turbojpeg-static - PATHS +find_library(TurboJPEG_LIBRARY + NAMES + libturbojpeg + turbojpeg + turbojpeg-static + PATHS "C:/libjpeg-turbo64" - PATH_SUFFIXES bin lib - ) -else() - find_path(TurboJPEG_INCLUDE_DIRS - NAMES turbojpeg.h - PATH_SUFFIXES include - ) - - find_library(TurboJPEG_LIBRARY - NAMES turbojpeg turbojpeg-static - PATH_SUFFIXES bin lib - ) -endif() - -if(TurboJPEG_INCLUDE_DIRS AND TurboJPEG_LIBRARY) - include(CheckCSourceCompiles) - include(CMakePushCheckState) - - cmake_push_check_state(RESET) - list(APPEND CMAKE_REQUIRED_INCLUDES ${TurboJPEG_INCLUDE_DIRS}) - list(APPEND CMAKE_REQUIRED_LIBRARIES ${TurboJPEG_LIBRARY}) - - check_c_source_compiles("#include \nint main(void) { tjhandle h=tjInitCompress(); return 0; }" TURBOJPEG_WORKS) - cmake_pop_check_state() -endif() + PATH_SUFFIXES + bin + lib +) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(TurboJPEG - FOUND_VAR TURBOJPEG_FOUND - REQUIRED_VARS TurboJPEG_LIBRARY TurboJPEG_INCLUDE_DIRS TURBOJPEG_WORKS - TurboJPEG_INCLUDE_DIRS TurboJPEG_LIBRARY + FOUND_VAR + TurboJPEG_FOUND + REQUIRED_VARS + TurboJPEG_LIBRARY + TurboJPEG_INCLUDE_DIR ) + +if(TurboJPEG_FOUND AND NOT TARGET turbojpeg) + add_library(turbojpeg UNKNOWN IMPORTED GLOBAL) + set_target_properties(turbojpeg PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${TurboJPEG_INCLUDE_DIR}" + IMPORTED_LOCATION "${TurboJPEG_LIBRARY}" + ) +endif() diff --git a/cmake/GitVersion.cmake b/cmake/GitVersion.cmake new file mode 100644 index 000000000..18f520e8a --- /dev/null +++ b/cmake/GitVersion.cmake @@ -0,0 +1,29 @@ +execute_process( + COMMAND git config --global --add safe.directory "*" + ERROR_QUIET +) + +execute_process( + COMMAND git log -1 --format=%cn-%t/%h-%ct + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE BUILD_ID + ERROR_QUIET +) + +execute_process( + COMMAND git symbolic-ref --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_ID + ERROR_QUIET +) + +execute_process( + COMMAND git config --get remote.origin.url + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REMOTE_PATH + ERROR_QUIET +) + +string(STRIP "${BUILD_ID}" HYPERION_BUILD_ID) +string(STRIP "${VERSION_ID}" HYPERION_VERSION_ID) +string(STRIP "${GIT_REMOTE_PATH}" HYPERION_GIT_REMOTE) diff --git a/cmake/HelperFunctions.cmake b/cmake/HelperFunctions.cmake new file mode 100644 index 000000000..88202cffd --- /dev/null +++ b/cmake/HelperFunctions.cmake @@ -0,0 +1,49 @@ +# Extract Major.Minor.Patch.Pre version from string +function(SetVersionNumber PREFIX VERSION_STRING) + string(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_.]+)" VERSION_PARTS ${VERSION_STRING}) + list(LENGTH VERSION_PARTS VERSION_LEN) + + if(${VERSION_LEN} GREATER 0) + list(GET VERSION_PARTS 0 VERSION_MAJOR) + endif() + + if(${VERSION_LEN} GREATER 1) + list(GET VERSION_PARTS 1 VERSION_MINOR) + endif() + + if(${VERSION_LEN} GREATER 2) + list(GET VERSION_PARTS 2 VERSION_PATCH) + endif() + + if(${VERSION_LEN} GREATER 3) + list(GET VERSION_PARTS 3 VERSION_PRE) + endif() + + set(${PREFIX}_VERSION_MAJOR ${VERSION_MAJOR} PARENT_SCOPE) + set(${PREFIX}_VERSION_MINOR ${VERSION_MINOR} PARENT_SCOPE) + set(${PREFIX}_VERSION_PATCH ${VERSION_PATCH} PARENT_SCOPE) + set(${PREFIX}_VERSION_PRE ${VERSION_PRE} PARENT_SCOPE) +endfunction() + +# Determine the current Platform and put the result into the OUTPUT var +function(DeterminePlatform OUTPUT) + set(_output "") + if(APPLE) + set(_output "osx") + elseif (WIN32) + set(_output "windows") + elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86") + set(_output "x11") + elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") + set(_output "rpi") + file(READ /proc/cpuinfo SYSTEM_CPUINFO) + string(TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO) + if("${SYSTEM_CPUINFO}" MATCHES "amlogic" AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4) + set(_output "amlogic") + elseif (("${SYSTEM_CPUINFO}" MATCHES "amlogic" OR "${SYSTEM_CPUINFO}" MATCHES "odroid-c2" OR "${SYSTEM_CPUINFO}" MATCHES "vero4k") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(_output "amlogic64") + endif() + endif() + + set(${OUTPUT} "${_output}" PARENT_SCOPE) +endfunction() diff --git a/cmake/HelperMacros.cmake b/cmake/HelperMacros.cmake new file mode 100644 index 000000000..9265b0c01 --- /dev/null +++ b/cmake/HelperMacros.cmake @@ -0,0 +1,24 @@ +macro(addIndent text) + if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") + list(APPEND CMAKE_MESSAGE_INDENT ${text}) + endif() +endmacro() + +macro(removeIndent) + if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") + list(POP_BACK CMAKE_MESSAGE_INDENT) + endif() +endmacro() + +# Macro to get path of first sub dir of a dir, used for MAC OSX lib/header searching +macro(FIRSTSUBDIR result curdir) + file(GLOB children RELATIVE ${curdir} ${curdir}/*) + set(dirlist "") + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + list(APPEND dirlist "${curdir}/${child}") + break() + endif() + endforeach() + set(${result} ${dirlist}) +endmacro() diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake new file mode 100644 index 000000000..5f9c58c93 --- /dev/null +++ b/cmake/Packaging.cmake @@ -0,0 +1,299 @@ +# cmake file for generating distribution packages + +# Default packages to build +if(APPLE) + set(CPACK_GENERATOR "DragNDrop") + set(CPACK_DMG_FORMAT "UDBZ" ) + # Overwrite CMAKE_SYSTEM_NAME for mac (visual) + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_SYSTEM_NAME "macOS") + endif() +elseif(UNIX) + set(CPACK_GENERATOR "TGZ") +elseif(WIN32) + set(CPACK_GENERATOR "ZIP" "NSIS") + # Overwrite CMAKE_SYSTEM_PROCESSOR for Windows (visual) + if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64") + set(CMAKE_SYSTEM_PROCESSOR "x64") + endif() +endif() + +# Determine packages by found generator executables +find_package(RpmBuilder) +if(RPM_BUILDER_FOUND) + message(STATUS "CPACK: Found RPM builder") + set(CPACK_GENERATOR ${CPACK_GENERATOR} "RPM") +endif() + +find_package(DebBuilder) +if(DEB_BUILDER_FOUND) + message(STATUS "CPACK: Found DEB builder") + set(CPACK_GENERATOR ${CPACK_GENERATOR} "DEB") +endif() + +# Parameter CPACK_SYSTEM_PROCESSOR overwrites CMAKE_SYSTEM_PROCESSOR +if(CPACK_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CPACK_SYSTEM_PROCESSOR}) +endif() + +# Apply to all packages, some of these can be overwritten with generator specific content +# https://cmake.org/cmake/help/v3.5/module/CPack.html + +set(CPACK_PACKAGE_NAME "Hyperion" ) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient light implementation" ) +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) + +if(NOT CMAKE_VERSION VERSION_LESS "3.18") + set(CPACK_ARCHIVE_THREADS 0) +endif() + +# Replease "+", as cmake/rpm has an issue if"+" occurs in CPACK_PACKAGE_VERSION +string(REPLACE "+" "." HYPERION_PACKAGE_VERSION ${HYPERION_VERSION}) +set(CPACK_PACKAGE_FILE_NAME "Hyperion-${HYPERION_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + +set(CPACK_PACKAGE_CONTACT "packages@hyperion-project.org") +set(CPACK_PACKAGE_VENDOR "hyperion-project") +set(CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" ) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "Hyperion" ) +set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-32px.png" ) + +set(CPACK_PACKAGE_VERSION_MAJOR "${HYPERION_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${HYPERION_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${HYPERION_VERSION_PATCH}") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" ) +set(CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" ) +set(CPACK_CREATE_DESKTOP_LINKS "hyperiond;Hyperion" ) + +# Append pre-release version to CPACK_PACKAGE_VERSION_PATCH ifexists +if(NOT "${HYPERION_VERSION_PRE}" STREQUAL "") + string(APPEND CPACK_PACKAGE_VERSION_PATCH ${HYPERION_VERSION_PRE}) +endif() + +# Specific CPack Package Generators +# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators + +# DEB (UNIX only) +# https://cmake.org/cmake/help/latest/cpack_gen/deb.html +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/prerm") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4 | libcec (>= 4.0)" ) +set(CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" ) + +# RPM (Unix Only) +# https://cmake.org/cmake/help/latest/cpack_gen/rpm.html +set(CPACK_RPM_PACKAGE_RELEASE 1 ) +set(CPACK_RPM_PACKAGE_LICENSE "MIT" ) +set(CPACK_RPM_PACKAGE_GROUP "Applications" ) +set(CPACK_RPM_PACKAGE_REQUIRES "libcec >= 4.0.0" ) +set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/preinst") +set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/postinst") +set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/linux/package-scripts/prerm") + +# DragNDrop (macOS only) +# https://cmake.org/cmake/help/latest/cpack_gen/dmg.html +if(APPLE) + set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/macos/PackageIcon.icns" ) + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE" ) + set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/cmake/macos/Background.png" ) + set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/macos/AppleScript.scpt" ) +endif() + +# NSIS (Windows only) +# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators#nsis +if(WIN32) + # Use custom script based on cpack nsis template + set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/nsis/template ${CMAKE_MODULE_PATH}) + + # Some path transformations + file(TO_NATIVE_PATH ${CPACK_PACKAGE_ICON} CPACK_PACKAGE_ICON) + string(REGEX REPLACE "\\\\" "\\\\\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON}) + + file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/windows/nsis/installer.ico" NSIS_HYP_ICO) + file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/windows/nsis/header.bmp" NSIS_HYP_LOGO_HORI) + file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/windows/nsis/logo.bmp" NSIS_HYP_LOGO_VERT) + + string(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_ICO "${NSIS_HYP_ICO}") + string(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_VERT "${NSIS_HYP_LOGO_VERT}") + string(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_HORI "${NSIS_HYP_LOGO_HORI}") + + set(CPACK_NSIS_MODIFY_PATH ON ) + set(CPACK_NSIS_MUI_ICON ${NSIS_HYP_ICO}) + set(CPACK_NSIS_MUI_UNIICON ${NSIS_HYP_ICO}) + set(CPACK_NSIS_MUI_HEADERIMAGE ${NSIS_HYP_LOGO_HORI} ) + set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${NSIS_HYP_LOGO_VERT}) + set(CPACK_NSIS_DISPLAY_NAME "Hyperion Ambient Light") + set(CPACK_NSIS_PACKAGE_NAME "Hyperion" ) + set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\hyperiond.exe") + set(CPACK_NSIS_HELP_LINK "https://www.hyperion-project.org") + set(CPACK_NSIS_URL_INFO_ABOUT "https://www.hyperion-project.org") + set(CPACK_NSIS_MUI_FINISHPAGE_RUN "hyperiond.exe") + set(CPACK_NSIS_BRANDING_TEXT "Hyperion-${HYPERION_VERSION}") + + # custom nsis plugin directory + set(CPACK_NSIS_EXTRA_DEFS "!addplugindir ${CMAKE_SOURCE_DIR}/cmake/windows/nsis/plugins") + + # additional hyperiond startmenu link, won't be created ifthe user disables startmenu links + set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Hyperion (Console).lnk' '$INSTDIR\\\\bin\\\\hyperiond.exe' '-d -c'") + set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Hyperion (Console).lnk'") +endif() + +# Define the install components +# See also https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Component-Install-With-CPack +# and https://cmake.org/cmake/help/latest/module/CPackComponent.html +set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") + +# Components base (All builds) +set(CPACK_COMPONENTS_ALL "Hyperion" ) + +# Optional compiled + +if(ENABLE_REMOTE_CTL) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_remote" ) +endif() + +# only include standalone grabber with build was with flatbuffer client +if(ENABLE_FLATBUF_CONNECT) + if(ENABLE_QT) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_qt" ) + endif() + if(ENABLE_AMLOGIC) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_aml" ) + endif() + if(ENABLE_V4L2) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_v4l2" ) + endif() + if(ENABLE_AUDIO) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_audio" ) + endif() + if(ENABLE_X11) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_x11" ) + endif() + if(ENABLE_XCB) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_xcb" ) + endif() + if(ENABLE_DISPMANX) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_dispmanx" ) + endif() + if(ENABLE_FB) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_framebuffer" ) + endif() + if(ENABLE_OSX) + set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_osx" ) + endif() +endif(ENABLE_FLATBUF_CONNECT) + +# Only include Hyperion to macOS dmg package (without standalone programs) +if(CPACK_GENERATOR MATCHES "DragNDrop" ) + LIST ( REMOVE_ITEM CPACK_COMPONENTS_ALL "hyperion_remote" "hyperion_qt" "hyperion_osx" ) +endif() + +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON ) +set(CPACK_DEB_COMPONENT_INSTALL ON ) +set(CPACK_RPM_COMPONENT_INSTALL ON ) + +set(CPACK_STRIP_FILES ON ) + +# no code after following line! +include(CPack) + +cpack_add_install_type(Full DISPLAY_NAME "Full") +cpack_add_install_type(Min DISPLAY_NAME "Minimal") +cpack_add_component_group(Runtime EXPANDED DESCRIPTION "Hyperion runtime") + +# Components base +cpack_add_component(Hyperion + DISPLAY_NAME "Hyperion" + DESCRIPTION "Hyperion runtime" + INSTALL_TYPES Full Min + GROUP Runtime + REQUIRED +) + +# optional components + +if(ENABLE_REMOTE_CTL) +cpack_add_component_group(Remote DESCRIPTION "hyperion-remote commandline tool") +cpack_add_component(hyperion_remote + DISPLAY_NAME "Hyperion Remote" + DESCRIPTION "Hyperion remote cli tool" + INSTALL_TYPES Full + GROUP Remote + DEPENDS Hyperion +) +endif() + +# only include standalone grabber with build was with flatbuffer client +if(ENABLE_FLATBUF_CONNECT) + cpack_add_component_group(Screencapture EXPANDED DESCRIPTION "Standalone Screencapture commandline programs") + if(ENABLE_QT) + cpack_add_component(hyperion_qt + DISPLAY_NAME "Qt Standalone Screencap" + DESCRIPTION "Qt based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_AMLOGIC) + cpack_add_component(hyperion_aml + DISPLAY_NAME "Amlogic Standalone Screencap" + DESCRIPTION "Amlogic based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_V4L2) + cpack_add_component(hyperion_v4l2 + DISPLAY_NAME "V4l2 Standalone Screencap" + DESCRIPTION "Video for Linux 2 based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_X11) + cpack_add_component(hyperion_x11 + DISPLAY_NAME "X11 Standalone Screencap" + DESCRIPTION "X11 based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_XCB) + cpack_add_component(hyperion_xcb + DISPLAY_NAME "XCB Standalone Screencap" + DESCRIPTION "XCB based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_DISPMANX) + cpack_add_component(hyperion_dispmanx + DISPLAY_NAME "RPi dispmanx Standalone Screencap" + DESCRIPTION "Raspbery Pi dispmanx based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_FB) + cpack_add_component(hyperion_framebuffer + DISPLAY_NAME "Framebuffer Standalone Screencap" + DESCRIPTION "Framebuffer based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() + if(ENABLE_OSX) + cpack_add_component(hyperion_osx + DISPLAY_NAME "Mac osx Standalone Screencap" + DESCRIPTION "Mac osx based standalone screen capture" + INSTALL_TYPES Full + GROUP Screencapture + DEPENDS Hyperion + ) + endif() +endif(ENABLE_FLATBUF_CONNECT) diff --git a/cmake/linux/BundleLinux.cmake.in b/cmake/linux/BundleLinux.cmake.in new file mode 100644 index 000000000..a2306edf7 --- /dev/null +++ b/cmake/linux/BundleLinux.cmake.in @@ -0,0 +1,121 @@ +set(PROJECT_NAME "@PROJECT_NAME@") +set(QMAKE_EXECUTABLE "@QMAKE_EXECUTABLE@") +set(OPENSSL_FOUND @OPENSSL_FOUND@) +set(PYTHON_MODULES_DIR "@PYTHON_MODULES_DIR@") +set(PYTHON_VERSION "@PYTHON_VERSION@") +set(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") + +set(SYSTEM_LIBS_SKIP + "libatomic" + "libc" + "libdbus" + "libdl" + "libexpat" + "libfontconfig" + "libgcc_s" + "libgcrypt" + "libglib" + "libglib-2" + "libgpg-error" + "liblz4" + "liblzma" + "libm" + "libpcre" + "libpcre2" + "libpthread" + "librt" + "libstdc++" + "libsystemd" + "libudev" + "libusb" + "libusb-1" + "libutil" + "libuuid" + "libz" +) + +# Extract dependencies ignoring the system ones +include(GetPrerequisites) +get_prerequisites("${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}" DEPENDENCIES 0 1 "" "") + +# Append symlink and non-symlink dependencies to the list +set(PREREQUISITE_LIBS "") +foreach(DEPENDENCY ${DEPENDENCIES}) + get_filename_component(resolved ${DEPENDENCY} NAME_WE) + list(FIND SYSTEM_LIBS_SKIP ${resolved} _index) + if(${_index} GREATER -1) + continue() # Skip system libraries + else() + gp_resolve_item("${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}" "${DEPENDENCY}" "" "" resolved_file) + get_filename_component(resolved_file ${resolved_file} ABSOLUTE) + gp_append_unique(PREREQUISITE_LIBS ${resolved_file}) + get_filename_component(file_canonical ${resolved_file} REALPATH) + gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) + endif() +endforeach() + +execute_process( + COMMAND + "${QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS + OUTPUT_VARIABLE + QT_PLUGINS_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Copy Qt plugins to 'share/hyperion/lib' +foreach(PLUGIN "platforms" "sqldrivers" "imageformats" "tls" "wayland-shell-integration") + if(EXISTS ${QT_PLUGINS_DIR}/${PLUGIN}) + file(GLOB files "${QT_PLUGINS_DIR}/${PLUGIN}/*.so") + foreach(file ${files}) + get_prerequisites(${file} PLUGINS 0 1 "" "") + foreach(DEPENDENCY ${PLUGINS}) + get_filename_component(resolved ${DEPENDENCY} NAME_WE) + list(FIND SYSTEM_LIBS_SKIP ${resolved} _index) + if(${_index} GREATER -1) + continue() # Skip system libraries + else() + gp_resolve_item("${file}" "${DEPENDENCY}" "" "" resolved_file) + get_filename_component(resolved_file ${resolved_file} ABSOLUTE) + gp_append_unique(PREREQUISITE_LIBS ${resolved_file}) + get_filename_component(file_canonical ${resolved_file} REALPATH) + gp_append_unique(PREREQUISITE_LIBS ${file_canonical}) + endif() + endforeach() + + file(INSTALL + FILES + ${file} + DESTINATION + "${CMAKE_INSTALL_PREFIX}/share/hyperion/lib/${PLUGIN}" + ) + endforeach() + endif() +endforeach() + +# Copy dependencies to 'share/hyperion/lib' +file(INSTALL FILES ${PREREQUISITE_LIBS} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperion/lib") + +# Create a qt.conf file in 'share/hyperion/bin' to override hard-coded search paths in Qt plugins +file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n") +file(INSTALL FILES "${CMAKE_BINARY_DIR}/qt.conf" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperion/bin") + +if(NOT PYTHON_MODULES_DIR STREQUAL "" AND NOT PYTHON_VERSION STREQUAL "") + # Copy Python modules to 'share/hyperion/lib/pythonMAJOR.MINOR' and ignore the unnecessary stuff listed below + string(REGEX MATCHALL "[0-9]+" VERSION ${PYTHON_VERSION}) + list(GET VERSION 0 PYTHON_VERSION_MAJOR) + list(GET VERSION 1 PYTHON_VERSION_MINOR) + file(INSTALL + FILES ${PYTHON_MODULES_DIR}/ + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperion/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" + PATTERN "*.pyc" EXCLUDE # compiled bytecodes + PATTERN "__pycache__" EXCLUDE # any cache + PATTERN "config-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}*" EXCLUDE # static libs + PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation + PATTERN "tkinter" EXCLUDE # Tk interface + PATTERN "lib-dynload/_tkinter.*" EXCLUDE + PATTERN "idlelib" EXCLUDE + PATTERN "turtle.py" EXCLUDE # Tk demo + PATTERN "test" EXCLUDE # unittest module + PATTERN "sitecustomize.py" EXCLUDE # site-specific configs + ) +endif() diff --git a/cmake/desktop/hyperion.desktop b/cmake/linux/desktop/hyperion.desktop similarity index 100% rename from cmake/desktop/hyperion.desktop rename to cmake/linux/desktop/hyperion.desktop diff --git a/cmake/desktop/hyperion.metainfo.xml b/cmake/linux/desktop/hyperion.metainfo.xml similarity index 97% rename from cmake/desktop/hyperion.metainfo.xml rename to cmake/linux/desktop/hyperion.metainfo.xml index bc1ac7e60..cca92956d 100644 --- a/cmake/desktop/hyperion.metainfo.xml +++ b/cmake/linux/desktop/hyperion.metainfo.xml @@ -22,6 +22,7 @@ https://poeditor.com/join/project/Y4F6vHRFjA + diff --git a/cmake/package-scripts/postinst b/cmake/linux/package-scripts/postinst similarity index 100% rename from cmake/package-scripts/postinst rename to cmake/linux/package-scripts/postinst diff --git a/cmake/package-scripts/preinst b/cmake/linux/package-scripts/preinst similarity index 100% rename from cmake/package-scripts/preinst rename to cmake/linux/package-scripts/preinst diff --git a/cmake/package-scripts/prerm b/cmake/linux/package-scripts/prerm similarity index 100% rename from cmake/package-scripts/prerm rename to cmake/linux/package-scripts/prerm diff --git a/cmake/osxbundle/AppleScript.scpt b/cmake/macos/AppleScript.scpt similarity index 100% rename from cmake/osxbundle/AppleScript.scpt rename to cmake/macos/AppleScript.scpt diff --git a/cmake/osxbundle/Background.png b/cmake/macos/Background.png similarity index 100% rename from cmake/osxbundle/Background.png rename to cmake/macos/Background.png diff --git a/cmake/macos/BundleMacOS.cmake.in b/cmake/macos/BundleMacOS.cmake.in new file mode 100644 index 000000000..06d7d5f89 --- /dev/null +++ b/cmake/macos/BundleMacOS.cmake.in @@ -0,0 +1,129 @@ +set(MAC_BUNDLE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/@MAC_BUNDLE_NAME@.app") +set(MAC_BUNDLE_INSTALL_BIN_DIR "${MAC_BUNDLE_INSTALL_DIR}/Contents/MacOS") +set(MAC_BUNDLE_INSTALL_LIB_DIR "${MAC_BUNDLE_INSTALL_DIR}/Contents/Frameworks") +set(MAC_BUNDLE_INSTALL_PLUGIN_DIR "${MAC_BUNDLE_INSTALL_DIR}/Contents/plugins") +set(MAC_BUNDLE_INSTALL_TMP_DIR "${MAC_BUNDLE_INSTALL_DIR}/Contents/tmp") +set(PYTHON_MODULES_DIR "@PYTHON_MODULES_DIR@") +set(PYTHON_VERSION "@PYTHON_VERSION@") + +foreach(QUERY "QT_INSTALL_PLUGINS" "QT_HOST_LIBS") + execute_process(COMMAND "@QMAKE_EXECUTABLE@" -query ${QUERY} OUTPUT_VARIABLE QUERY_OUT OUTPUT_STRIP_TRAILING_WHITESPACE) + set(${QUERY} "${QUERY_OUT}") +endforeach() + +if(EXISTS ${MAC_BUNDLE_INSTALL_BIN_DIR}/@MAC_BUNDLE_NAME@) + file(GET_RUNTIME_DEPENDENCIES + EXECUTABLES + ${MAC_BUNDLE_INSTALL_BIN_DIR}/@MAC_BUNDLE_NAME@ + RESOLVED_DEPENDENCIES_VAR + DEPS_RESOLVED + UNRESOLVED_DEPENDENCIES_VAR + DEPS_UNRESOLVED + ) + + foreach(dependency ${DEPS_UNRESOLVED}) + message(WARNING "Runtime dependency ${dependency} could not be resolved.") + endforeach() + + foreach(dependency ${DEPS_RESOLVED}) + if(dependency MATCHES "\\.(dylib)$") + file(INSTALL + FILES + ${dependency} + DESTINATION + ${MAC_BUNDLE_INSTALL_LIB_DIR} + TYPE SHARED_LIBRARY + ) + else() + file(INSTALL + FILES + ${dependency} + DESTINATION + ${MAC_BUNDLE_INSTALL_TMP_DIR} + TYPE SHARED_LIBRARY + FOLLOW_SYMLINK_CHAIN + ) + endif() + endforeach() + + foreach(plugin "platforms" "sqldrivers" "imageformats" "tls") + if(EXISTS ${QT_INSTALL_PLUGINS}/${plugin}) + file(GLOB files "${QT_INSTALL_PLUGINS}/${plugin}/*.dylib") + list(FILTER files EXCLUDE REGEX ".*(sqlodbc|sqlpsql)\\.(dylib)$") + + file(GET_RUNTIME_DEPENDENCIES + LIBRARIES + ${files} + RESOLVED_DEPENDENCIES_VAR + DEPS_RESOLVED + UNRESOLVED_DEPENDENCIES_VAR + DEPS_UNRESOLVED + ) + + file(INSTALL + FILES + ${DEPS_RESOLVED} + DESTINATION + ${MAC_BUNDLE_INSTALL_TMP_DIR} + TYPE + SHARED_LIBRARY + FOLLOW_SYMLINK_CHAIN + ) + + file(INSTALL + FILES + ${files} + DESTINATION + ${MAC_BUNDLE_INSTALL_PLUGIN_DIR}/${plugin} + TYPE + SHARED_LIBRARY + ) + + foreach(dependency ${DEPS_UNRESOLVED}) + message(WARNING "Qt plugin dependency ${dependency} could not be resolved.") + endforeach() + endif() + endforeach() + + include(BundleUtilities) + file(GLOB_RECURSE QT_PLUGINS LIST_DIRECTORIES OFF "${MAC_BUNDLE_INSTALL_PLUGIN_DIR}/*") + fixup_bundle("${MAC_BUNDLE_INSTALL_DIR}" "${QT_PLUGINS}" "${MAC_BUNDLE_INSTALL_TMP_DIR};${QT_HOST_LIBS}" IGNORE_ITEM "Python") + file(REMOVE_RECURSE "${MAC_BUNDLE_INSTALL_TMP_DIR}") + + if(NOT PYTHON_MODULES_DIR STREQUAL "" AND NOT PYTHON_VERSION STREQUAL "") + string(REGEX MATCHALL "[0-9]+" VERSION ${PYTHON_VERSION}) + list(GET VERSION 0 PYTHON_VERSION_MAJOR) + list(GET VERSION 1 PYTHON_VERSION_MINOR) + set(PYTHON_FRAMEWORK "${MAC_BUNDLE_INSTALL_DIR}/Contents/Frameworks/Python.framework") + file(INSTALL + FILES ${PYTHON_MODULES_DIR}/ + DESTINATION "${PYTHON_FRAMEWORK}/Versions/Current/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" + PATTERN "*.pyc" EXCLUDE # compiled bytecodes + PATTERN "__pycache__" EXCLUDE # any cache + PATTERN "config-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}*" EXCLUDE # static libs + PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation + PATTERN "tkinter" EXCLUDE # Tk interface + PATTERN "lib-dynload/_tkinter.*" EXCLUDE + PATTERN "idlelib" EXCLUDE + PATTERN "turtle.py" EXCLUDE # Tk demo + PATTERN "test" EXCLUDE # unittest module + PATTERN "sitecustomize.py" EXCLUDE # site-specific configs + ) + endif() + + file(GLOB_RECURSE LIBS FOLLOW_SYMLINKS "${MAC_BUNDLE_INSTALL_DIR}/*.dylib") + file(GLOB FRAMEWORKS FOLLOW_SYMLINKS LIST_DIRECTORIES ON "${MAC_BUNDLE_INSTALL_LIB_DIR}/*") + foreach(item ${LIBS} ${FRAMEWORKS} ${PYTHON_FRAMEWORK} ${MAC_BUNDLE_INSTALL_DIR}) + set(cmd codesign --deep --force --sign - "${item}") + execute_process( + COMMAND ${cmd} + RESULT_VARIABLE codesign_result + ) + + if(NOT codesign_result EQUAL 0) + message(WARNING "macOS signing failed; ${cmd} returned ${codesign_result}") + endif() + endforeach() +elseif(EXISTS ${MAC_BUNDLE_INSTALL_DIR}) + file(REMOVE_RECURSE ${MAC_BUNDLE_INSTALL_DIR}) +endif() diff --git a/cmake/osxbundle/Hyperion.icns b/cmake/macos/Hyperion.icns similarity index 100% rename from cmake/osxbundle/Hyperion.icns rename to cmake/macos/Hyperion.icns diff --git a/cmake/osxbundle/Info.plist.in b/cmake/macos/Info.plist.in similarity index 92% rename from cmake/osxbundle/Info.plist.in rename to cmake/macos/Info.plist.in index d6c77d509..0cfac9f14 100644 --- a/cmake/osxbundle/Info.plist.in +++ b/cmake/macos/Info.plist.in @@ -7,9 +7,9 @@ CFBundleIdentifier ${MACOSX_BUNDLE_GUI_IDENTIFIER} CFBundleName - Hyperion + ${MACOSX_BUNDLE_BUNDLE_NAME} CFBundleExecutable - Hyperion + ${MACOSX_BUNDLE_BUNDLE_NAME} CFBundleIconFile ${MACOSX_BUNDLE_ICON_FILE} CFBundleGetInfoString diff --git a/cmake/osxbundle/PackageIcon.icns b/cmake/macos/PackageIcon.icns similarity index 100% rename from cmake/osxbundle/PackageIcon.icns rename to cmake/macos/PackageIcon.icns diff --git a/cmake/packages.cmake b/cmake/packages.cmake deleted file mode 100644 index a6701545e..000000000 --- a/cmake/packages.cmake +++ /dev/null @@ -1,293 +0,0 @@ -# cmake file for generating distribution packages - -# Default packages to build -IF (APPLE) - SET ( CPACK_GENERATOR "DragNDrop") - SET ( CPACK_DMG_FORMAT "UDBZ" ) -ELSEIF (UNIX) - SET ( CPACK_GENERATOR "TGZ") -ELSEIF (WIN32) - SET ( CPACK_GENERATOR "ZIP" "NSIS") -ENDIF() - -# Determine packages by found generator executables -find_package(RpmBuilder) -IF(RPM_BUILDER_FOUND) - message(STATUS "CPACK: Found RPM builder") - SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "RPM") -ENDIF() - -find_package(DebBuilder) -IF(DEB_BUILDER_FOUND) - message(STATUS "CPACK: Found DEB builder") - SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "DEB") -ENDIF() - -# Overwrite CMAKE_SYSTEM_NAME for mac (visual) -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(${CMAKE_HOST_APPLE}) - set(CMAKE_SYSTEM_NAME "macOS") - endif() -endif() - -# Overwrite CMAKE_SYSTEM_PROCESSOR for Windows (visual) -if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64") - if(${CMAKE_HOST_WIN32}) - set(CMAKE_SYSTEM_PROCESSOR "x64") - endif() -endif() - -# Apply to all packages, some of these can be overwritten with generator specific content -# https://cmake.org/cmake/help/v3.5/module/CPack.html - -SET ( CPACK_PACKAGE_NAME "Hyperion" ) -SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient light implementation" ) -SET ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) - -# Replease "+", as cmake/rpm has an issue if "+" occurs in CPACK_PACKAGE_VERSION -string(REPLACE "+" "." HYPERION_PACKAGE_VERSION ${HYPERION_VERSION}) -SET ( CPACK_PACKAGE_FILE_NAME "Hyperion-${HYPERION_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") - -SET ( CPACK_PACKAGE_CONTACT "packages@hyperion-project.org") -SET ( CPACK_PACKAGE_VENDOR "hyperion-project") -SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" ) -SET ( CPACK_PACKAGE_INSTALL_DIRECTORY "Hyperion" ) -SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-32px.png" ) - -SET ( CPACK_PACKAGE_VERSION_MAJOR "${HYPERION_VERSION_MAJOR}") -SET ( CPACK_PACKAGE_VERSION_MINOR "${HYPERION_VERSION_MINOR}") -SET ( CPACK_PACKAGE_VERSION_PATCH "${HYPERION_VERSION_PATCH}") -SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" ) -SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" ) -SET ( CPACK_CREATE_DESKTOP_LINKS "hyperiond;Hyperion" ) - -# Append pre-release version to CPACK_PACKAGE_VERSION_PATCH if exists -if (NOT "${HYPERION_VERSION_PRE}" STREQUAL "") - string(APPEND CPACK_PACKAGE_VERSION_PATCH ${HYPERION_VERSION_PRE}) -endif() - -# Specific CPack Package Generators -# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators - -# .deb files for apt -# https://cmake.org/cmake/help/latest/cpack_gen/deb.html -SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" ) -SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4 | libcec (>= 4.0)" ) -SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" ) - -# .rpm for rpm -# https://cmake.org/cmake/help/latest/cpack_gen/rpm.html -SET ( CPACK_RPM_PACKAGE_RELEASE 1 ) -SET ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -SET ( CPACK_RPM_PACKAGE_GROUP "Applications" ) -SET ( CPACK_RPM_PACKAGE_REQUIRES "libcec >= 4.0.0" ) -SET ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst" ) -SET ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst" ) -SET ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" ) - -# .dmg for Apple macOS -# https://cmake.org/cmake/help/latest/cpack_gen/dmg.html -IF (APPLE) - SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/osxbundle/PackageIcon.icns" ) - SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE" ) - SET ( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/cmake/osxbundle/Background.png" ) - SET ( CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/osxbundle/AppleScript.scpt" ) -ENDIF(APPLE) - -# Windows NSIS -# Use custom script based on cpack nsis template -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/nsis/template ${CMAKE_MODULE_PATH}) - -# Some path transformations -if(WIN32) - file(TO_NATIVE_PATH ${CPACK_PACKAGE_ICON} CPACK_PACKAGE_ICON) - STRING(REGEX REPLACE "\\\\" "\\\\\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON}) -endif() -file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico" NSIS_HYP_ICO) -file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/header.bmp" NSIS_HYP_LOGO_HORI) -file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/logo.bmp" NSIS_HYP_LOGO_VERT) -STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_ICO "${NSIS_HYP_ICO}") -STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_VERT "${NSIS_HYP_LOGO_VERT}") -STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_HORI "${NSIS_HYP_LOGO_HORI}") - -SET ( CPACK_NSIS_MODIFY_PATH ON ) -SET ( CPACK_NSIS_MUI_ICON ${NSIS_HYP_ICO}) -SET ( CPACK_NSIS_MUI_UNIICON ${NSIS_HYP_ICO}) -SET ( CPACK_NSIS_MUI_HEADERIMAGE ${NSIS_HYP_LOGO_HORI} ) -SET ( CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${NSIS_HYP_LOGO_VERT}) -SET ( CPACK_NSIS_DISPLAY_NAME "Hyperion Ambient Light") -SET ( CPACK_NSIS_PACKAGE_NAME "Hyperion" ) -SET ( CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\hyperiond.exe") -SET ( CPACK_NSIS_HELP_LINK "https://www.hyperion-project.org") -SET ( CPACK_NSIS_URL_INFO_ABOUT "https://www.hyperion-project.org") -SET ( CPACK_NSIS_MUI_FINISHPAGE_RUN "hyperiond.exe") -SET ( CPACK_NSIS_BRANDING_TEXT "Hyperion-${HYPERION_VERSION}") - -# custom nsis plugin directory -SET ( CPACK_NSIS_EXTRA_DEFS "!addplugindir ${CMAKE_SOURCE_DIR}/cmake/nsis/plugins") - -# additional hyperiond startmenu link, won't be created if the user disables startmenu links -SET ( CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Hyperion (Console).lnk' '$INSTDIR\\\\bin\\\\hyperiond.exe' '-d -c'") -SET ( CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Hyperion (Console).lnk'") - -# Define the install components -# See also https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Component-Install-With-CPack -# and https://cmake.org/cmake/help/latest/module/CPackComponent.html -SET ( CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") - -# Components base (All builds) -SET ( CPACK_COMPONENTS_ALL "Hyperion" ) - -# Optional compiled - -if(ENABLE_REMOTE_CTL) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_remote" ) -endif() - -# only include standalone grabber with build was with flatbuffer client -if(ENABLE_FLATBUF_CONNECT) - if(ENABLE_QT) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_qt" ) - endif() - if(ENABLE_AMLOGIC) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_aml" ) - endif() - if(ENABLE_V4L2) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_v4l2" ) - endif() - if(ENABLE_AUDIO) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_audio" ) - endif() - if(ENABLE_X11) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_x11" ) - endif() - if(ENABLE_XCB) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_xcb" ) - endif() - if(ENABLE_DISPMANX) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_dispmanx" ) - endif() - if(ENABLE_FB) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_framebuffer" ) - endif() - if(ENABLE_OSX) - SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_osx" ) - endif() -endif(ENABLE_FLATBUF_CONNECT) - -# Only include Hyperion to macOS dmg package (without standalone programs) -IF ( CPACK_GENERATOR MATCHES "DragNDrop" ) - LIST ( REMOVE_ITEM CPACK_COMPONENTS_ALL "hyperion_remote" "hyperion_qt" "hyperion_osx" ) -ENDIF() - -SET ( CPACK_ARCHIVE_COMPONENT_INSTALL ON ) -SET ( CPACK_DEB_COMPONENT_INSTALL ON ) -SET ( CPACK_RPM_COMPONENT_INSTALL ON ) - -SET ( CPACK_STRIP_FILES ON ) - -# no code after following line! -INCLUDE ( CPack ) - -cpack_add_install_type(Full DISPLAY_NAME "Full") -cpack_add_install_type(Min DISPLAY_NAME "Minimal") -cpack_add_component_group(Runtime EXPANDED DESCRIPTION "Hyperion runtime") - -# Components base -cpack_add_component(Hyperion - DISPLAY_NAME "Hyperion" - DESCRIPTION "Hyperion runtime" - INSTALL_TYPES Full Min - GROUP Runtime - REQUIRED -) - -# optional components - -if(ENABLE_REMOTE_CTL) -cpack_add_component_group(Remote DESCRIPTION "hyperion-remote commandline tool") -cpack_add_component(hyperion_remote - DISPLAY_NAME "Hyperion Remote" - DESCRIPTION "Hyperion remote cli tool" - INSTALL_TYPES Full - GROUP Remote - DEPENDS Hyperion -) -endif() - -# only include standalone grabber with build was with flatbuffer client -if(ENABLE_FLATBUF_CONNECT) - cpack_add_component_group(Screencapture EXPANDED DESCRIPTION "Standalone Screencapture commandline programs") - if(ENABLE_QT) - cpack_add_component(hyperion_qt - DISPLAY_NAME "Qt Standalone Screencap" - DESCRIPTION "Qt based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_AMLOGIC) - cpack_add_component(hyperion_aml - DISPLAY_NAME "Amlogic Standalone Screencap" - DESCRIPTION "Amlogic based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_V4L2) - cpack_add_component(hyperion_v4l2 - DISPLAY_NAME "V4l2 Standalone Screencap" - DESCRIPTION "Video for Linux 2 based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_X11) - cpack_add_component(hyperion_x11 - DISPLAY_NAME "X11 Standalone Screencap" - DESCRIPTION "X11 based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_XCB) - cpack_add_component(hyperion_xcb - DISPLAY_NAME "XCB Standalone Screencap" - DESCRIPTION "XCB based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_DISPMANX) - cpack_add_component(hyperion_dispmanx - DISPLAY_NAME "RPi dispmanx Standalone Screencap" - DESCRIPTION "Raspbery Pi dispmanx based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_FB) - cpack_add_component(hyperion_framebuffer - DISPLAY_NAME "Framebuffer Standalone Screencap" - DESCRIPTION "Framebuffer based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() - if(ENABLE_OSX) - cpack_add_component(hyperion_osx - DISPLAY_NAME "Mac osx Standalone Screencap" - DESCRIPTION "Mac osx based standalone screen capture" - INSTALL_TYPES Full - GROUP Screencapture - DEPENDS Hyperion - ) - endif() -endif(ENABLE_FLATBUF_CONNECT) diff --git a/cmake/version.cmake b/cmake/version.cmake deleted file mode 100644 index 5d03370bc..000000000 --- a/cmake/version.cmake +++ /dev/null @@ -1,30 +0,0 @@ -function(SetVersionNumber PREFIX VERSION_STRING) - - STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_.]+)" VERSION_PARTS ${VERSION_STRING} ) - LIST( LENGTH VERSION_PARTS VERSION_LEN) - if(${VERSION_LEN} GREATER 0) - LIST( GET VERSION_PARTS 0 VERSION_MAJOR ) - endif() - - if(${VERSION_LEN} GREATER 1) - LIST( GET VERSION_PARTS 1 VERSION_MINOR ) - endif() - - if(${VERSION_LEN} GREATER 2) - LIST( GET VERSION_PARTS 2 VERSION_PATCH ) - endif() - - if(${VERSION_LEN} GREATER 3) - LIST( GET VERSION_PARTS 3 VERSION_PRE ) - endif() - - set(${PREFIX}_VERSION_MAJOR ${VERSION_MAJOR} PARENT_SCOPE) - set(${PREFIX}_VERSION_MINOR ${VERSION_MINOR} PARENT_SCOPE) - set(${PREFIX}_VERSION_PATCH ${VERSION_PATCH} PARENT_SCOPE) - set(${PREFIX}_VERSION_PRE ${VERSION_PRE} PARENT_SCOPE) - - #if(NOT VERSION_PRE MATCHES "stable") - # set(${PREFIX}_VERSION_PRE ${VERSION_PRE} PARENT_SCOPE) - # set( VERSION_PRE_FULL "-${VERSION_PRE}") - #endif() -endfunction() diff --git a/cmake/windows/BundleWindows.cmake.in b/cmake/windows/BundleWindows.cmake.in new file mode 100644 index 000000000..23601bb40 --- /dev/null +++ b/cmake/windows/BundleWindows.cmake.in @@ -0,0 +1,164 @@ +set(ENABLE_MF @ENABLE_MF@) +set(ENABLE_DX @ENABLE_DX@) +set(OPENSSL_FOUND @OPENSSL_FOUND@) +set(TurboJPEG_INCLUDE_DIR "@TurboJPEG_INCLUDE_DIR@") +set(PYTHON_VERSION "@PYTHON_VERSION@") +set(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") +set(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") + +# Set windeployqt args +set(ARGS --dry-run --no-opengl-sw --list mapping) +if(@QT_VERSION_MAJOR@ EQUAL 5) + set(EXTRA_ARGS --no-angle) +endif() + +if(EXISTS @CMAKE_BINARY_DIR@/bin/@PROJECT_NAME@@CMAKE_EXECUTABLE_SUFFIX@) + # Collect the runtime libraries + get_filename_component(QT_BIN_DIR "${QMAKE_EXECUTABLE}" DIRECTORY) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E env "PATH=${QT_BIN_DIR}" "@WINDEPLOYQT_EXECUTABLE@" + ${ARGS} + ${EXTRA_ARGS} + "@CMAKE_BINARY_DIR@/bin/@PROJECT_NAME@@CMAKE_EXECUTABLE_SUFFIX@" + WORKING_DIRECTORY "${QT_BIN_DIR}/.." + OUTPUT_VARIABLE DEPS + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Parse DEPS into a semicolon-separated list. + separate_arguments(DEPENDENCIES WINDOWS_COMMAND ${DEPS}) + string(REPLACE "\\" "/" DEPENDENCIES "${DEPENDENCIES}") + + # Copy dependencies to 'hyperion/lib' or 'hyperion' + while(DEPENDENCIES) + list(GET DEPENDENCIES 0 src) + list(GET DEPENDENCIES 1 dst) + get_filename_component(dst ${dst} DIRECTORY) + + if(NOT ${dst} STREQUAL "") + set(DESTINATION_DIR "lib/${dst}") + else() + set(DESTINATION_DIR "bin") + endif() + + file(INSTALL + FILES + ${src} + DESTINATION + ${CMAKE_INSTALL_PREFIX}/${DESTINATION_DIR} + ) + + list(REMOVE_AT DEPENDENCIES 0 1) + endwhile() + + # Create a qt.conf file in 'bin' to override hard-coded search paths in Qt plugins + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n") + file(INSTALL FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") + + # Copy libjpeg-turbo to 'hyperion' + if(ENABLE_MF AND NOT TurboJPEG_INCLUDE_DIR STREQUAL "") + get_filename_component(TURBOJPEG_DIR "${TurboJPEG_INCLUDE_DIR}" DIRECTORY) + foreach(comp "turbojpeg" "jpeg62") + find_file(${comp} + NAMES + "${comp}.dll" + PATHS + ${TURBOJPEG_DIR} + PATH_SUFFIXES + bin + ) + + file(INSTALL FILES ${${comp}} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") + endforeach() + endif() + + if(NOT PYTHON_VERSION STREQUAL "") + set(PYTHON_EMBED_URL "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip") + get_filename_component(PYTHON_EMBED_ARCHIVE ${PYTHON_EMBED_URL} NAME) + + # Download embed python package (release build only) + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_EMBED_ARCHIVE}") + message(STATUS "Downloading ${PYTHON_EMBED_ARCHIVE}...") + file(DOWNLOAD + ${PYTHON_EMBED_URL} + ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_EMBED_ARCHIVE} + SHOW_PROGRESS + STATUS result + ) + + # Check if the download is successful + list(GET result 0 result_code) + if(NOT result_code EQUAL 0) + list(GET result 1 reason) + message(FATAL_ERROR "Could not download file ${PYTHON_EMBED_ARCHIVE}: ${reason}") + endif() + endif() + + # Unpack downloaded embed python + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/python") + message(STATUS "Extracting ${PYTHON_EMBED_ARCHIVE}...") + file(ARCHIVE_EXTRACT + INPUT + ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_EMBED_ARCHIVE} + DESTINATION + ${CMAKE_CURRENT_BINARY_DIR}/python + ) + endif() + + # Copy python library and archive to 'hyperion' + string(REGEX MATCHALL "[0-9]+" VERSION ${PYTHON_VERSION}) + list(GET VERSION 0 PYTHON_VERSION_MAJOR) + list(GET VERSION 1 PYTHON_VERSION_MINOR) + set(PYTHON_LIB "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll") + set(PYTHON_ZIP "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.zip") + if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_LIB}" AND EXISTS "${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_ZIP}") + file(INSTALL + FILES + ${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_LIB} + ${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_ZIP} + DESTINATION + "${CMAKE_INSTALL_PREFIX}/bin" + ) + endif() + endif() + + if(ENABLE_DX) + set(DIRECTX_REDIST_URL "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe") + get_filename_component(DIRECTX_REDIST_FILE ${DIRECTX_REDIST_URL} NAME) + + # Download DirectX End-User Runtimes (June 2010) + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe") + message(STATUS "Downloading ${DIRECTX_REDIST_FILE}...") + file(DOWNLOAD + ${DIRECTX_REDIST_URL} + ${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe + SHOW_PROGRESS + STATUS result + ) + + # Check if the download is successful + list(GET result 0 result_code) + if(NOT result_code EQUAL 0) + list(GET result 1 reason) + message(FATAL_ERROR "Could not download file ${DIRECTX_REDIST_FILE}: ${reason}") + endif() + endif() + + # Copy DirectX End-User Runtimes to 'hyperion' + if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/bin/dx_redist.exe") + file(INSTALL + FILES + "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe" + DESTINATION + "${CMAKE_INSTALL_PREFIX}/bin" + ) + endif() + endif() + + file(INSTALL + FILES + "${CMAKE_SOURCE_DIR}/effects/readme.txt" + DESTINATION + "${CMAKE_INSTALL_PREFIX}/effects" + ) +endif() diff --git a/cmake/nsis/header.bmp b/cmake/windows/nsis/header.bmp similarity index 100% rename from cmake/nsis/header.bmp rename to cmake/windows/nsis/header.bmp diff --git a/cmake/nsis/installer.ico b/cmake/windows/nsis/installer.ico similarity index 100% rename from cmake/nsis/installer.ico rename to cmake/windows/nsis/installer.ico diff --git a/cmake/nsis/logo.bmp b/cmake/windows/nsis/logo.bmp similarity index 100% rename from cmake/nsis/logo.bmp rename to cmake/windows/nsis/logo.bmp diff --git a/cmake/nsis/plugins/FindProcDLL.dll b/cmake/windows/nsis/plugins/FindProcDLL.dll similarity index 100% rename from cmake/nsis/plugins/FindProcDLL.dll rename to cmake/windows/nsis/plugins/FindProcDLL.dll diff --git a/cmake/nsis/template/NSIS.InstallOptions.ini.in b/cmake/windows/nsis/template/NSIS.InstallOptions.ini.in similarity index 100% rename from cmake/nsis/template/NSIS.InstallOptions.ini.in rename to cmake/windows/nsis/template/NSIS.InstallOptions.ini.in diff --git a/cmake/nsis/template/NSIS.template.in b/cmake/windows/nsis/template/NSIS.template.in similarity index 100% rename from cmake/nsis/template/NSIS.template.in rename to cmake/windows/nsis/template/NSIS.template.in diff --git a/cmake/win/win.rc.in b/cmake/windows/win.rc.in similarity index 100% rename from cmake/win/win.rc.in rename to cmake/windows/win.rc.in diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index eea412f1f..3c3477c85 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -1,11 +1,23 @@ +# ============================================================================= +# HIDAPI +# ============================================================================= + if (ENABLE_DEV_USB_HID) add_subdirectory(build/hidapi) endif() +#============================================================================= +# Tinkerforge +#============================================================================= + if (ENABLE_DEV_TINKERFORGE) add_subdirectory(build/tinkerforge) endif() +#============================================================================= +# rpi_ws281x +#============================================================================= + if(ENABLE_DEV_WS281XPWM) add_library(ws281x external/rpi_ws281x/mailbox.c external/rpi_ws281x/ws2811.c diff --git a/include/effectengine/EffectModule.h b/include/effectengine/EffectModule.h index 44c3bd2f4..bccf562d3 100644 --- a/include/effectengine/EffectModule.h +++ b/include/effectengine/EffectModule.h @@ -1,8 +1,18 @@ #pragma once #undef slots +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG #include -#define slots +#define _DEBUG +#else +#include +#endif +#define slots Q_SLOTS #include diff --git a/include/python/PythonInit.h b/include/python/PythonInit.h index 316d84642..257245d8e 100644 --- a/include/python/PythonInit.h +++ b/include/python/PythonInit.h @@ -1,7 +1,17 @@ #pragma once #undef slots +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG +#include +#define _DEBUG +#else #include +#endif #define slots Q_SLOTS /// diff --git a/include/python/PythonProgram.h b/include/python/PythonProgram.h index 4b3d05fea..ea5648c7a 100644 --- a/include/python/PythonProgram.h +++ b/include/python/PythonProgram.h @@ -3,11 +3,19 @@ #include #include -// Python includes -// collide of qt slots macro #undef slots -#include "Python.h" -#define slots +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG +#include +#define _DEBUG +#else +#include +#endif +#define slots Q_SLOTS #include diff --git a/include/python/PythonUtils.h b/include/python/PythonUtils.h index 10574fc11..b6f373530 100644 --- a/include/python/PythonUtils.h +++ b/include/python/PythonUtils.h @@ -1,7 +1,17 @@ #pragma once #undef slots +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG +#include +#define _DEBUG +#else #include +#endif #define slots Q_SLOTS // decl diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index 5bbc03e4b..24c990385 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -1,8 +1,3 @@ - -# Define the current source locations -set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include) -set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc) - add_subdirectory(hyperion) add_subdirectory(commandline) add_subdirectory(blackborder) @@ -13,11 +8,11 @@ if(ENABLE_BOBLIGHT_SERVER) endif() if(ENABLE_FLATBUF_SERVER OR ENABLE_FLATBUF_CONNECT) -add_subdirectory(flatbufserver) + add_subdirectory(flatbufserver) endif() if(ENABLE_PROTOBUF_SERVER) -add_subdirectory(protoserver) + add_subdirectory(protoserver) endif() if(ENABLE_FORWARDER) diff --git a/libsrc/effectengine/CMakeLists.txt b/libsrc/effectengine/CMakeLists.txt index 27ba48c01..381264bb2 100644 --- a/libsrc/effectengine/CMakeLists.txt +++ b/libsrc/effectengine/CMakeLists.txt @@ -28,3 +28,9 @@ target_link_libraries(effectengine Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui ) + +if(NOT CMAKE_VERSION VERSION_LESS "3.15") + set_target_properties(effectengine PROPERTIES + ADDITIONAL_CLEAN_FILES ${CMAKE_BINARY_DIR}/EffectEngine.qrc + ) +endif() diff --git a/libsrc/effectengine/EffectEngine.cpp b/libsrc/effectengine/EffectEngine.cpp index 2c5ab5214..84d21e9f9 100644 --- a/libsrc/effectengine/EffectEngine.cpp +++ b/libsrc/effectengine/EffectEngine.cpp @@ -1,5 +1,14 @@ -// Python includes +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG #include +#define _DEBUG +#else +#include +#endif #undef B0 // Qt includes diff --git a/libsrc/grabber/video/CMakeLists.txt b/libsrc/grabber/video/CMakeLists.txt index ab447738d..ec365f4a3 100644 --- a/libsrc/grabber/video/CMakeLists.txt +++ b/libsrc/grabber/video/CMakeLists.txt @@ -29,9 +29,7 @@ if(ENABLE_V4L2 OR ENABLE_MF) find_package(TurboJPEG) if(TURBOJPEG_FOUND) target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_TURBO_JPEG) - message(STATUS "Using Turbo JPEG library: ${TurboJPEG_LIBRARY}") - target_link_libraries(${PROJECT_NAME} ${TurboJPEG_LIBRARY}) - target_include_directories(${PROJECT_NAME} PUBLIC ${TurboJPEG_INCLUDE_DIRS}) + target_link_libraries(${PROJECT_NAME} turbojpeg) else () message(STATUS "Turbo JPEG library not found, MJPEG camera format won't work.") endif() diff --git a/libsrc/python/CMakeLists.txt b/libsrc/python/CMakeLists.txt index d39d34af3..63710c5c1 100644 --- a/libsrc/python/CMakeLists.txt +++ b/libsrc/python/CMakeLists.txt @@ -6,12 +6,31 @@ add_library(python ${CMAKE_SOURCE_DIR}/libsrc/python/PythonProgram.cpp ) -if(NOT CMAKE_VERSION VERSION_LESS "3.12") - find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(CMAKE_VERSION VERSION_LESS "3.12") + find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED) else() - find_package (PythonLibs ${PYTHON_VERSION_STRING} EXACT) + find_package(Python3 COMPONENTS Interpreter Development QUIET REQUIRED) + set(PYTHON_VERSION_STRING ${Python3_VERSION}) + set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR}) + set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR}) + set(Python_STDLIB ${Python3_STDLIB}) endif() +define_property(TARGET PROPERTY PYTHON_VERSION_PROPERTY + BRIEF_DOCS "Python version property" + FULL_DOCS "Python version property" +) + +define_property(TARGET PROPERTY PYTHON_STDLIB_LOCATION_PROPERTY + BRIEF_DOCS "Python stdlib location property" + FULL_DOCS "Python stdlib location property" +) + +set_target_properties(python PROPERTIES + PYTHON_VERSION_PROPERTY ${PYTHON_VERSION_STRING} + PYTHON_STDLIB_LOCATION_PROPERTY ${Python_STDLIB} +) + target_link_libraries(python effectengine hyperion-utils @@ -25,6 +44,6 @@ target_include_directories(python PUBLIC ) target_compile_definitions(python PRIVATE - PYTHON_VERSION_MAJOR=$<$:${Python3_VERSION_MAJOR}>$<$:${PYTHON_VERSION_MAJOR}> - PYTHON_VERSION_MINOR=$<$:${Python3_VERSION_MINOR}>$<$:${PYTHON_VERSION_MINOR}> + PYTHON_VERSION_MAJOR=${PYTHON_VERSION_MAJOR} + PYTHON_VERSION_MINOR=${PYTHON_VERSION_MINOR} ) diff --git a/libsrc/utils/SysInfo.cpp b/libsrc/utils/SysInfo.cpp index da8758c79..f05e47ab4 100644 --- a/libsrc/utils/SysInfo.cpp +++ b/libsrc/utils/SysInfo.cpp @@ -1,9 +1,18 @@ #include "HyperionConfig.h" #if defined(ENABLE_EFFECTENGINE) -// Python includes +// Don't use debug Python APIs on Windows +#if defined(_MSC_VER) && defined(_DEBUG) +#if _MSC_VER >= 1930 +#include +#endif +#undef _DEBUG +#include +#define _DEBUG +#else #include #endif +#endif #include "utils/SysInfo.h" #include "utils/FileUtils.h" diff --git a/libsrc/webserver/CMakeLists.txt b/libsrc/webserver/CMakeLists.txt index 70c670522..575ced93c 100644 --- a/libsrc/webserver/CMakeLists.txt +++ b/libsrc/webserver/CMakeLists.txt @@ -44,3 +44,17 @@ target_link_libraries(webserver if(ENABLE_MDNS) target_link_libraries(webserver mdns) endif() + +find_package(OpenSSL QUIET) +if(OPENSSL_FOUND AND TARGET OpenSSL::SSL AND TARGET OpenSSL::Crypto) + target_link_libraries(webserver + OpenSSL::SSL + OpenSSL::Crypto + ) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "3.15") + set_target_properties(webserver PROPERTIES + ADDITIONAL_CLEAN_FILES ${CMAKE_BINARY_DIR}/WebConfig.qrc + ) +endif() diff --git a/src/hyperion-aml/CMakeLists.txt b/src/hyperion-aml/CMakeLists.txt index fea62f349..3d84f3986 100644 --- a/src/hyperion-aml/CMakeLists.txt +++ b/src/hyperion-aml/CMakeLists.txt @@ -23,10 +23,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_aml") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_aml" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_aml") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_aml") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_aml") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperion-dispmanx/CMakeLists.txt b/src/hyperion-dispmanx/CMakeLists.txt index c81d0fdbe..66790b8d7 100644 --- a/src/hyperion-dispmanx/CMakeLists.txt +++ b/src/hyperion-dispmanx/CMakeLists.txt @@ -22,10 +22,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_dispmanx") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_dispmanx" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_dispmanx") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_dispmanx") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_dispmanx") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperion-framebuffer/CMakeLists.txt b/src/hyperion-framebuffer/CMakeLists.txt index 8ac51da4d..784883006 100644 --- a/src/hyperion-framebuffer/CMakeLists.txt +++ b/src/hyperion-framebuffer/CMakeLists.txt @@ -22,10 +22,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_framebuffer") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_framebuffer" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_framebuffer") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_framebuffer") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_framebuffer") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperion-osx/CMakeLists.txt b/src/hyperion-osx/CMakeLists.txt index 48a127b7c..1df4c53f2 100644 --- a/src/hyperion-osx/CMakeLists.txt +++ b/src/hyperion-osx/CMakeLists.txt @@ -22,4 +22,4 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_osx") +install(TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_osx" OPTIONAL) diff --git a/src/hyperion-qt/CMakeLists.txt b/src/hyperion-qt/CMakeLists.txt index fe87ef8b2..905a26f04 100644 --- a/src/hyperion-qt/CMakeLists.txt +++ b/src/hyperion-qt/CMakeLists.txt @@ -3,8 +3,8 @@ project(hyperion-qt) if(WIN32) # generate windows .rc file for this binary - string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico) - configure_file(${CMAKE_SOURCE_DIR}/cmake/win/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) + string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/windows/nsis/installer.ico) + configure_file(${CMAKE_SOURCE_DIR}/cmake/windows/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) set(WIN_RC_FILE ${CMAKE_BINARY_DIR}/win.rc) endif() @@ -30,11 +30,11 @@ else() endif() if(APPLE) - install (TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_qt") + install(TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_qt" OPTIONAL) elseif(NOT WIN32) - install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_qt") + install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_qt" OPTIONAL) else() - install (TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "hyperion_qt") + install(TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "hyperion_qt" OPTIONAL) endif() if(CMAKE_HOST_UNIX AND NOT APPLE) diff --git a/src/hyperion-remote/CMakeLists.txt b/src/hyperion-remote/CMakeLists.txt index 8046fc15b..febcc8628 100644 --- a/src/hyperion-remote/CMakeLists.txt +++ b/src/hyperion-remote/CMakeLists.txt @@ -3,8 +3,8 @@ project(hyperion-remote) if(WIN32) # generate windows .rc file for this binary - string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico) - configure_file(${CMAKE_SOURCE_DIR}/cmake/win/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) + string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/windows/nsis/installer.ico) + configure_file(${CMAKE_SOURCE_DIR}/cmake/windows/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) set(WIN_RC_FILE ${CMAKE_BINARY_DIR}/win.rc) endif() @@ -32,11 +32,11 @@ if(ENABLE_EFFECTENGINE) endif() if(APPLE) - install (TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_remote") + install(TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_remote" OPTIONAL) elseif(NOT WIN32) - install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_remote") + install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_remote" OPTIONAL) else() - install (TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "hyperion_remote") + install(TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "hyperion_remote" OPTIONAL) endif() if(CMAKE_HOST_UNIX AND NOT APPLE) diff --git a/src/hyperion-v4l2/CMakeLists.txt b/src/hyperion-v4l2/CMakeLists.txt index 92aadb28c..30caf405c 100644 --- a/src/hyperion-v4l2/CMakeLists.txt +++ b/src/hyperion-v4l2/CMakeLists.txt @@ -22,10 +22,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_v4l2") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_v4l2" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_v4l2") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_v4l2") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_v4l2") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperion-x11/CMakeLists.txt b/src/hyperion-x11/CMakeLists.txt index 20ca0f7ac..357ccfae9 100644 --- a/src/hyperion-x11/CMakeLists.txt +++ b/src/hyperion-x11/CMakeLists.txt @@ -26,10 +26,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_x11") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_x11" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_x11") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_x11") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_x11") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperion-xcb/CMakeLists.txt b/src/hyperion-xcb/CMakeLists.txt index 98b2ba323..a85ec1711 100644 --- a/src/hyperion-xcb/CMakeLists.txt +++ b/src/hyperion-xcb/CMakeLists.txt @@ -22,10 +22,10 @@ else() target_link_libraries(${PROJECT_NAME} ssdp) endif() -install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_xcb") +install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_xcb" OPTIONAL) if(CMAKE_HOST_UNIX) install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "hyperion_xcb") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME "${PROJECT_NAME}" COMPONENT "hyperion_xcb") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "hyperion_xcb") -endif(CMAKE_HOST_UNIX) +endif() diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 092260ad8..4c5733772 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -1,27 +1,41 @@ -if(APPLE) - project(Hyperion) -else() - project(hyperiond) -endif() +project(hyperiond) ##################################### ############ Preparation ############ ##################################### +get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + if(WIN32) # generate windows .rc file for this binary - string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico) - configure_file(${CMAKE_SOURCE_DIR}/cmake/win/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) + string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/windows/nsis/installer.ico) + configure_file(${CMAKE_SOURCE_DIR}/cmake/windows/win.rc.in ${CMAKE_BINARY_DIR}/win.rc) set(WIN_RC_FILE ${CMAKE_BINARY_DIR}/win.rc) # promote hyperiond as GUI app set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") + + # Search for windeployqt target (qt6 has the target natively) otherwise create it. + if(NOT TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + get_filename_component(QT_BIN_DIR ${QMAKE_EXECUTABLE} DIRECTORY) + find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS ${QT_BIN_DIR}) + if(EXISTS ${WINDEPLOYQT_EXECUTABLE}) + add_executable(Qt${QT_VERSION_MAJOR}::windeployqt IMPORTED) + set_target_properties(Qt${QT_VERSION_MAJOR}::windeployqt PROPERTIES + IMPORTED_LOCATION ${WINDEPLOYQT_EXECUTABLE} + ) + else() + message(WARNING "Cannot find the windeployqt tool.") + endif() + endif() elseif(APPLE) # include resource files for macos bundle (copy LICENSE file and correct line breaks) configure_file(${CMAKE_SOURCE_DIR}/LICENSE ${CMAKE_BINARY_DIR}/LICENSE COPYONLY) execute_process(COMMAND bash -c "perl -pi -e 's/\n/\r/g' ${CMAKE_BINARY_DIR}/LICENSE") - set(MACOS_BUNDLE_RESOURCE_FILES ${CMAKE_SOURCE_DIR}/cmake/osxbundle/Hyperion.icns ${CMAKE_BINARY_DIR}/LICENSE) - set_source_files_properties(${MACOS_BUNDLE_RESOURCE_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + set(MACOS_BUNDLE_RESOURCE_FILES ${CMAKE_SOURCE_DIR}/cmake/macos/Hyperion.icns ${CMAKE_BINARY_DIR}/LICENSE) + set_source_files_properties(${MACOS_BUNDLE_RESOURCE_FILES} PROPERTIES + MACOSX_PACKAGE_LOCATION Resources + ) endif() ##################################### @@ -59,8 +73,10 @@ if(Qt${QT_VERSION_MAJOR}DBus_FOUND) target_link_libraries(${PROJECT_NAME} "Qt${QT_VERSION_MAJOR}::DBus") endif() -if(ENABLE_EFFECTENGINE) +if(ENABLE_EFFECTENGINE AND TARGET python) target_link_libraries(${PROJECT_NAME} effectengine python) + get_target_property(PYTHON_VERSION python PYTHON_VERSION_PROPERTY) + get_target_property(PYTHON_MODULES_DIR python PYTHON_STDLIB_LOCATION_PROPERTY) endif() if(ENABLE_FLATBUF_SERVER) @@ -73,15 +89,15 @@ endif() if(ENABLE_DISPMANX) target_link_libraries(${PROJECT_NAME} dispmanx-grabber) -endif (ENABLE_DISPMANX) +endif() if(ENABLE_FB) target_link_libraries(${PROJECT_NAME} framebuffer-grabber) -endif (ENABLE_FB) +endif() if(ENABLE_OSX) target_link_libraries(${PROJECT_NAME} osx-grabber) -endif (ENABLE_OSX) +endif() if(ENABLE_V4L2) target_link_libraries(${PROJECT_NAME} v4l2-grabber) @@ -89,7 +105,10 @@ endif() if(ENABLE_MF) target_link_libraries(${PROJECT_NAME} mf-grabber) -endif (ENABLE_MF) + if(TARGET turbojpeg) + get_target_property(TurboJPEG_INCLUDE_DIR turbojpeg INTERFACE_INCLUDE_DIRECTORIES) + endif() +endif() if(ENABLE_AUDIO) target_link_libraries(hyperiond audio-grabber) @@ -97,34 +116,34 @@ endif() if(ENABLE_AMLOGIC) target_link_libraries(${PROJECT_NAME} amlogic-grabber) -endif (ENABLE_AMLOGIC) +endif() if(ENABLE_X11) if(APPLE) include_directories("/opt/X11/include") - endif(APPLE) + endif() target_link_libraries(${PROJECT_NAME} x11-grabber) -endif (ENABLE_X11) +endif() if(ENABLE_XCB) target_link_libraries(${PROJECT_NAME} xcb-grabber) -endif (ENABLE_XCB) +endif() if(ENABLE_QT) target_link_libraries(${PROJECT_NAME} qt-grabber) -endif (ENABLE_QT) +endif() if(ENABLE_DX) target_link_libraries(${PROJECT_NAME} directx-grabber) -endif (ENABLE_DX) +endif() if(ENABLE_DDA) target_link_libraries(${PROJECT_NAME} dda-grabber) -endif (ENABLE_DDA) +endif() if(ENABLE_CEC) target_link_libraries(${PROJECT_NAME} cechandler) -endif (ENABLE_CEC) +endif() if(ENABLE_MDNS) target_link_libraries(${PROJECT_NAME} mdns) @@ -135,25 +154,30 @@ endif() ##################################### if(APPLE) + # set bundle information + set(MAC_BUNDLE_NAME "Hyperion") set_target_properties(${PROJECT_NAME} PROPERTIES - MACOSX_BUNDLE TRUE - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/osxbundle/Info.plist.in - MACOSX_BUNDLE_BUNDLE_NAME "Hyperion" + OUTPUT_NAME ${MAC_BUNDLE_NAME} + MACOSX_BUNDLE ON + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/cmake/macos/Info.plist.in" + MACOSX_BUNDLE_BUNDLE_NAME ${MAC_BUNDLE_NAME} MACOSX_BUNDLE_BUNDLE_VERSION ${HYPERION_VERSION} MACOSX_BUNDLE_COPYRIGHT "Copyright(c) 2014-2024 Hyperion Project" - MACOSX_BUNDLE_GUI_IDENTIFIER "com.hyperion-project.${PROJECT_NAME}" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.hyperion-project.${MAC_BUNDLE_NAME}" MACOSX_BUNDLE_ICON_FILE "Hyperion.icns" - MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${HYPERION_VERSION}" + MACOSX_BUNDLE_INFO_STRING "${MAC_BUNDLE_NAME} ${HYPERION_VERSION}" MACOSX_BUNDLE_SHORT_VERSION_STRING ${HYPERION_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${HYPERION_VERSION} ) - install (TARGETS ${PROJECT_NAME} DESTINATION . COMPONENT "Hyperion") + install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION . COMPONENT "Hyperion") + configure_file("${CMAKE_SOURCE_DIR}/cmake/macos/BundleMacOS.cmake.in" "${PROJECT_BINARY_DIR}/BundleMacOS.cmake" @ONLY) + install(SCRIPT "${PROJECT_BINARY_DIR}/BundleMacOS.cmake" COMPONENT "Hyperion") elseif(NOT WIN32) # install Hyperion/service files/effect folder - install (TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "Hyperion") - install (DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion" COMPONENT "Hyperion") - install (FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "share/hyperion/effects" COMPONENT "Hyperion") + install(TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "Hyperion") + install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion" COMPONENT "Hyperion") + install(FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "share/hyperion/effects" COMPONENT "Hyperion") # install Hyperion icons set(ICON_SIZES 16 22 24 32 36 48 64 72 96 128 192 256 512) @@ -164,18 +188,29 @@ elseif(NOT WIN32) endforeach(size) # install desktop/appstream file - install (FILES ${CMAKE_SOURCE_DIR}/cmake/desktop/hyperion.metainfo.xml DESTINATION "share/hyperion/desktop" COMPONENT "Hyperion") - install (FILES ${CMAKE_SOURCE_DIR}/cmake/desktop/hyperion.desktop DESTINATION "share/hyperion/desktop" COMPONENT "Hyperion") -else() - install (TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "Hyperion") - install (FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "effects" COMPONENT "Hyperion") -endif() + install(FILES ${CMAKE_SOURCE_DIR}/cmake/linux/desktop/hyperion.metainfo.xml DESTINATION "share/hyperion/desktop" COMPONENT "Hyperion") + install(FILES ${CMAKE_SOURCE_DIR}/cmake/linux/desktop/hyperion.desktop DESTINATION "share/hyperion/desktop" COMPONENT "Hyperion") -if(CMAKE_HOST_UNIX AND NOT APPLE) + # create symlink and copy "updateHyperionUser.sh" script install(CODE "execute_process(COMMAND ln -sf \"../share/hyperion/bin/${PROJECT_NAME}\" \"${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}\")" COMPONENT "Hyperion") install(FILES "${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME}" DESTINATION "bin" RENAME ${PROJECT_NAME} COMPONENT "Hyperion") install(CODE "file (REMOVE ${CMAKE_BINARY_DIR}/symlink_${PROJECT_NAME})" COMPONENT "Hyperion") install(FILES ${CMAKE_SOURCE_DIR}/bin/scripts/updateHyperionUser.sh DESTINATION "share/hyperion/scripts" COMPONENT "Hyperion") + + if(ENABLE_DEPLOY_DEPENDENCIES) + configure_file("${CMAKE_SOURCE_DIR}/cmake/linux/BundleLinux.cmake.in" "${PROJECT_BINARY_DIR}/BundleLinux.cmake" @ONLY) + install(SCRIPT "${PROJECT_BINARY_DIR}/BundleLinux.cmake" COMPONENT "Hyperion") + endif() +else() + install(TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT "Hyperion" OPTIONAL) + install(FILES ${CMAKE_SOURCE_DIR}/effects/readme.txt DESTINATION "effects" COMPONENT "Hyperion") + + if(TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + get_target_property(WINDEPLOYQT_EXECUTABLE Qt${QT_VERSION_MAJOR}::windeployqt IMPORTED_LOCATION) + endif() + + configure_file("${CMAKE_SOURCE_DIR}/cmake/windows/BundleWindows.cmake.in" "${PROJECT_BINARY_DIR}/BundleWindows.cmake" @ONLY) + install(SCRIPT "${PROJECT_BINARY_DIR}/BundleWindows.cmake" COMPONENT "Hyperion") endif() ###################################### @@ -184,25 +219,16 @@ endif() # Deploy Qt DLLs into the binary folder. # This is necessary for starting the application from within the IDE - -if(WIN32) - get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) - get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY) - find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}") - - if(NOT WINDEPLOYQT_EXECUTABLE) - find_program(WINDEPLOYQT_EXECUTABLE windeployqt) - endif() - - if(WINDEPLOYQT_EXECUTABLE AND NOT CMAKE_GITHUB_ACTION) - set(WINDEPLOYQT_PARAMS_RUNTIME --verbose 0 --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler) - message(STATUS "Found windeployqt: ${WINDEPLOYQT_EXECUTABLE} PATH_HINT:${QT_BIN_DIR}") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} ${WINDEPLOYQT_PARAMS_RUNTIME} "$") +if(WIN32 AND NOT DEFINED ENV{GITHUB_ACTIONS}) + if(TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + set(WINDEPLOYQT_PARAMS --verbose 0 --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND Qt${QT_VERSION_MAJOR}::windeployqt ${WINDEPLOYQT_PARAMS} "$" + ) endif() - find_package(OpenSSL REQUIRED) if(OPENSSL_FOUND) - string(REGEX MATCHALL "[0-9]+" openssl_versions "${OPENSSL_VERSION}") + string(REGEX MATCHALL "[0-9]+" openssl_versions ${OPENSSL_VERSION}) list(GET openssl_versions 0 openssl_version_major) list(GET openssl_versions 1 openssl_version_minor) @@ -217,36 +243,20 @@ if(WIN32) string(APPEND open_ssl_version_suffix "-x64") endif() - find_file(OPENSSL_SSL - NAMES "libssl${open_ssl_version_suffix}.dll" - PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin - NO_DEFAULT_PATH - ) - - find_file(OPENSSL_CRYPTO - NAMES "libcrypto${open_ssl_version_suffix}.dll" - PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin - NO_DEFAULT_PATH - ) - - add_custom_command( - TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${OPENSSL_SSL} ${OPENSSL_CRYPTO} - $ - ) - endif(OPENSSL_FOUND) -endif(WIN32) - -if(ENABLE_DEPLOY_DEPENDENCIES) - # Deploy all dependencies for package creation - include(${CMAKE_SOURCE_DIR}/cmake/Dependencies.cmake) - - if(APPLE) #macOS - DeployMacOS(${PROJECT_NAME}) - elseif (NOT WIN32) # Linux - DeployLinux(${PROJECT_NAME}) - elseif(WIN32) # Windows - DeployWindows(${PROJECT_NAME}) + get_filename_component(OPENSSL_DIR "${OPENSSL_INCLUDE_DIR}" DIRECTORY) + foreach(comp "ssl" "crypto") + find_file(${comp} + NAMES + "lib${comp}${open_ssl_version_suffix}.dll" + PATHS + ${OPENSSL_DIR} + PATH_SUFFIXES + bin + ) + + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${${comp}} $ + ) + endforeach() endif() -endif(ENABLE_DEPLOY_DEPENDENCIES) +endif()