diff --git a/.circleci/config.yml b/.circleci/config.yml index bed151dc..d051c6fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,28 +24,6 @@ flatpak-steps: &flatpak-steps - run: ci/git-push.sh /build-flatpak jobs: - build-buster: - docker: - - image: circleci/buildpack-deps:bullseye-scm - environment: - - OCPN_TARGET: bullseye - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-buster.sh - - run: sh -c "ci/maybe-push-upload.sh" - - build-buster-armhf: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - environment: - - CMAKE_BUILD_PARALLEL_LEVEL: 2 - steps: - - checkout - - run: ci/circleci-build-buster-armhf.sh - - run: ci/maybe-push-upload.sh - build-bullseye: docker: - image: circleci/buildpack-deps:bullseye-scm @@ -66,7 +44,7 @@ jobs: build-bullseye-armhf: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2204:current resource_class: arm.medium environment: - TARGET_TUPLE: debian;11;armhf @@ -80,7 +58,7 @@ jobs: build-bullseye-wx32-armhf: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2204:current resource_class: arm.medium environment: - TARGET_TUPLE: debian-wx32;11;armhf @@ -96,7 +74,7 @@ jobs: build-bullseye-arm64: machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2204:current resource_class: arm.medium environment: - OCPN_TARGET: bullseye @@ -110,7 +88,7 @@ jobs: build-bullseye-wx32-arm64: machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2204:current resource_class: arm.medium environment: - OCPN_TARGET: bullseye @@ -126,7 +104,7 @@ jobs: build-bookworm: machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2204:current resource_class: medium environment: - OCPN_TARGET: bookworm @@ -140,7 +118,7 @@ jobs: build-bookworm-arm64: machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2204:current resource_class: arm.medium environment: - OCPN_TARGET: bookworm @@ -154,7 +132,7 @@ jobs: build-bookworm-armhf: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2204:current resource_class: arm.medium environment: - TARGET_TUPLE: debian;12;armhf @@ -168,7 +146,7 @@ jobs: build-flatpak-arm64: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2204:current resource_class: arm.medium environment: - OCPN_TARGET: flatpak-arm64 @@ -182,7 +160,7 @@ jobs: build-flatpak-x86: machine: - image: ubuntu-2004:202010-01 + image: ubuntu-2204:current environment: - OCPN_TARGET: flatpak - CMAKE_BUILD_PARALLEL_LEVEL: 2 @@ -195,7 +173,7 @@ jobs: build-macos: macos: - xcode: "12.5.1" + xcode: "15.2.0" environment: - OCPN_TARGET: macos - CMAKE_BUILD_PARALLEL_LEVEL: 2 @@ -203,12 +181,14 @@ jobs: - checkout - run: sudo chmod go+w /usr/local - restore_cache: - key: "{{checksum \"build-deps/macos-cache-stamp\"}}\ + key: "new-{{checksum \"build-deps/macos-cache-stamp\"}}\ + -{{checksum \"build-deps/macos-deps\"}}\ -{{checksum \"cmake/MacosWxwidgets.cmake\"}}\ -{{checksum \"ci/circleci-build-macos.sh\"}}" - run: ci/circleci-build-macos.sh - save_cache: - key: "{{checksum \"build-deps/macos-cache-stamp\"}}\ + key: "new-{{checksum \"build-deps/macos-cache-stamp\"}}\ + -{{checksum \"build-deps/macos-deps\"}}\ -{{checksum \"cmake/MacosWxwidgets.cmake\"}}\ -{{checksum \"ci/circleci-build-macos.sh\"}}" paths: @@ -295,9 +275,3 @@ workflows: - build-bookworm: <<: *std-filters - - - build-buster: - <<: *std-filters - - - build-buster-armhf: - <<: *std-filters diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..087ecf9a --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,66 @@ +--- +# yamllint disable rule:line-length +name: Linux build + +on: + push: + branches: + - master + - ci_update + paths-ignore: + - 'manual/**' + pull_request: + branches: + - master + paths-ignore: + - 'manual/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + runs-on: ${{ matrix.runner }} + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu latest wxGTK 3 + runner: ubuntu-latest + cmake_generator: Unix Makefiles + + env: + wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }} + + # Use bash as the shell, even under MSW where the default is PowerShell. + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Before build + run: | + ./ci/github-pre-build.sh + env: + USE_HOMEBREW: ${{ matrix.use_homebrew && matrix.use_homebrew || 0 }} + + - name: Configure CMake + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }} + + - name: Build + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: Test + if: runner.os != 'Linux' + # TODO: The tests do not work in headless Linux containers (GTK crashes) with wxWidgets 3.0 available in Ubuntu + # They seem to be fine with wx 3.1 though, so we will just remove the condition "later" when wx3.2 time comes + # On Windows, we would need opencpn.exe in the worjing directory to run the tests (and wxWidgets libs in the path) + working-directory: build + run: ctest -C ${{env.BUILD_TYPE}} +... diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..4501d12e --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,99 @@ +--- +# yamllint disable rule:line-length +name: macOS build + +on: + push: + branches: + - '*' + paths-ignore: + - 'manual/**' + tags: + - '*' + pull_request: + branches: + - '*' + paths-ignore: + - 'manual/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + runs-on: ${{ matrix.runner }} + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: macOS 'latest' Homebrew wxOSX + runner: macos-latest + cmake_generator: Xcode + cmake_defines: -DCMAKE_CXX_STANDARD=17 + use_homebrew: 1 + push_cloudsmith: 0 + - name: macOS 14 Homebrew wxOSX + runner: macos-14 + cmake_generator: Ninja + cmake_defines: -DCMAKE_CXX_STANDARD=17 + use_homebrew: 1 + push_cloudsmith: 0 + - name: macOS 13 Homebrew wxOSX + runner: macos-13 + cmake_generator: Ninja + cmake_defines: -DCMAKE_CXX_STANDARD=17 + use_homebrew: 1 + push_cloudsmith: 0 + #- name: macOS 11 wxOSX + # runner: macos-11 + # cmake_generator: Xcode + # cmake_defines: -DCMAKE_CXX_STANDARD=11 -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx322-2_opencpn50_macos1010/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx322-2_opencpn50_macos1010" + # push_cloudsmith: 1 + #- name: macOS 10.15 wxOSX + # runner: macos-10.15 + # cmake_generator: Xcode + # cmake_defines: -DCMAKE_CXX_STANDARD=11 -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx322-2_opencpn50_macos1010/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx322-2_opencpn50_macos1010" + + env: + wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }} + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} + + # Use bash as the shell, even under MSW where the default is PowerShell. + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Before build + run: | + ./ci/github-pre-build.sh + env: + USE_HOMEBREW: ${{ matrix.use_homebrew && matrix.use_homebrew || 0 }} + + - name: Configure CMake + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }} + + - name: Build + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: Upload to Cloudsmith + if: matrix.push_cloudsmith == 1 + run: | + ./upload.sh + working-directory: build + env: + UPLOAD_CLOUDSMITH: ${{ matrix.push_cloudsmith }} + + - name: Test + # TODO: The tests do not work in headless Linux containers (GTK crashes) with wxWidgets 3.0 available in Ubuntu + # They seem to be fine with wx 3.1 though, so we will just remove the condition "later" when wx3.2 time comes + # On Windows, we would need opencpn.exe in the worjing directory to run the tests (and wxWidgets libs in the path) + working-directory: build + run: ctest -C ${{env.BUILD_TYPE}} +... diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..fd5e1e19 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,74 @@ +--- +# yamllint disable rule:line-length +name: Windows 32bit build + +on: + push: + branches: + - master + - ci_update + paths-ignore: + - 'manual/**' + tags: + - '*' + pull_request: + branches: + - master + paths-ignore: + - 'manual/**' + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} + + +jobs: + build: + runs-on: ${{ matrix.runner }} + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: Windows MSVC + runner: windows-latest + no_sudo: 1 + # TODO: Tests don't link on Windows, investigate and fix later + cmake_defines: -T v143 -DCMAKE_GENERATOR_PLATFORM=win32 -DWITH_TESTS=OFF -DCMAKE_CXX_STANDARD=17 + + env: + wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }} + + # Use bash as the shell, even under MSW where the default is PowerShell. + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + # required for CMake to find Ninja + - name: "[Windows] Set up MSVC Developer Command Prompt" + if: runner.os == 'Windows' + uses: seanmiddleditch/gha-setup-vsdevenv@v3 + with: + host_arch: x86 + arch: win32 + + - name: "[Windows] Dependencies, configure, build" + if: runner.os == 'Windows' + run: | + call buildwin/win_deps.bat + cmake -A win32 -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }} + cmake --build build --config ${{env.BUILD_TYPE}} + shell: cmd + - name: "[Windows] Publish to Cloudsmith" + if: runner.os == 'Windows' + run: | + cd build + .\upload.bat + shell: cmd +... diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc5d684..15756808 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,10 @@ # License: GPLv3+ # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. # -------- Cmake setup --------- # @@ -15,15 +15,14 @@ cmake_minimum_required(VERSION 3.12.0) include(${CMAKE_SOURCE_DIR}/cmake/CmakeSetup.cmake NO_POLICY_SCOPE) message(STATUS "Cmake version: ${CMAKE_VERSION}.") - # -------- Build setup -------- # include(PluginOptions) -if (BUILD_TYPE) +if(BUILD_TYPE) message(STATUS "Building: ${BUILD_TYPE}") -else () +else() message(STATUS "Configuring") -endif () +endif() # -------- Plugin setup ---------- # @@ -33,92 +32,90 @@ include(Plugin.cmake) # project(${PKG_NAME} VERSION ${PKG_VERSION}) include(PluginCompiler) +if(NOT WIN32 + AND NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" + AND NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") + message(STATUS "CPU: ${CMAKE_SYSTEM_PROCESSOR}") + add_compile_options(-msse4.2 -maes) +endif() add_library(${CMAKE_PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SRC}) include_directories(BEFORE ${CMAKE_BINARY_DIR}/include) add_subdirectory("opencpn-libs/${PKG_API_LIB}") -if (${PKG_NAME} MATCHES wx32) +if(${PKG_NAME} MATCHES wx32) target_link_libraries(${CMAKE_PROJECT_NAME} ocpn::api_wx32) -else () +else() target_link_libraries(${CMAKE_PROJECT_NAME} ocpn::api) -endif () +endif() set(VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(VERSION_MINOR ${PROJECT_VERSION_MINOR}) set(VERSION_PATCH ${PROJECT_VERSION_PATCH}) +if(PROJECT_VERSION_TWEAK STREQUAL "") + set(PROJECT_VERSION_TWEAK 0) +endif() set(PACKAGE_NAME ${CMAKE_PROJECT_NAME}) # Create the minimim ocpn version id string like ov50 -string(REGEX REPLACE "\([0-9]\)\.\([0-9]\).*" "ov\\1\\2" - OCPN_MIN_VERSION ${API_OCPN_MIN_VERSION}) +string(REGEX REPLACE "\([0-9]\)\.\([0-9]\).*" "ov\\1\\2" OCPN_MIN_VERSION + ${API_OCPN_MIN_VERSION}) -if (COMMAND late_init) +if(COMMAND late_init) late_init() -endif () +endif() # Configure the flatpak manifest -file( - GLOB manifest ${PROJECT_SOURCE_DIR}/flatpak/org.opencpn.OpenCPN.Plugin.*.yaml -) +file(GLOB manifest + ${PROJECT_SOURCE_DIR}/flatpak/org.opencpn.OpenCPN.Plugin.*.yaml) include(ConfigureManifest) configure_manifest(${manifest} _new_manifest) -# Set up targets. Targets sets up new targets with BUILD_TYPE set to -# 'flatpak', 'android' or 'tarball'. The initial call without BUILD_TYPE ends -# here. +# Set up targets. Targets sets up new targets with BUILD_TYPE set to 'flatpak', +# 'android' or 'tarball'. The initial call without BUILD_TYPE ends here. # include(Targets) create_targets(${_new_manifest}) -if ("${BUILD_TYPE}" STREQUAL "") - return () -endif () +if("${BUILD_TYPE}" STREQUAL "") + return() +endif() - -if (NOT ${BUILD_TYPE} STREQUAL "flatpak") +if(NOT ${BUILD_TYPE} STREQUAL "flatpak") # Build package as required (flatpak already dealt with). # - if (APPLE) + if(APPLE) include(MacosWxwidgets) - endif () + endif() include(PluginInstall) - if (QT_ANDROID) + if(QT_ANDROID) include(AndroidLibs) - else () + else() include(PluginLibs) - endif () + endif() include(PluginLocalization) include_directories(BEFORE ${CMAKE_BINARY_DIR}/include) - - if (COMMAND add_plugin_libraries) + + if(COMMAND add_plugin_libraries) add_plugin_libraries() - endif () + endif() -endif () +endif() -configure_file( - ${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/include//config.h - @ONLY -) +configure_file(${CMAKE_SOURCE_DIR}/config.h.in + ${CMAKE_BINARY_DIR}/include//config.h @ONLY) configure_file( # The cloudsmith upload script - ${CMAKE_SOURCE_DIR}/ci/upload.sh.in ${CMAKE_BINARY_DIR}/upload.sh - @ONLY -) + ${CMAKE_SOURCE_DIR}/ci/upload.sh.in ${CMAKE_BINARY_DIR}/upload.sh @ONLY) configure_file( # The cloudsmith upload script, windows bat file. - ${CMAKE_SOURCE_DIR}/ci/upload.bat.in ${CMAKE_BINARY_DIR}/upload.bat - @ONLY -) + ${CMAKE_SOURCE_DIR}/ci/upload.bat.in ${CMAKE_BINARY_DIR}/upload.bat @ONLY) -set(checksum "@checksum@") +set(FILE_CHECKSUM "@checksum@") configure_file( # The XML metadata file ${CMAKE_SOURCE_DIR}/plugin.xml.in - ${CMAKE_BINARY_DIR}/${pkg_displayname}.xml.in - @ONLY -) + ${CMAKE_BINARY_DIR}/${pkg_displayname}.xml.in @ONLY) diff --git a/build-deps/0001-matrix.h-Patch-attributes-handling-wxwidgets-22790.patch b/build-deps/0001-matrix.h-Patch-attributes-handling-wxwidgets-22790.patch index d05788e2..4330f3cf 100644 --- a/build-deps/0001-matrix.h-Patch-attributes-handling-wxwidgets-22790.patch +++ b/build-deps/0001-matrix.h-Patch-attributes-handling-wxwidgets-22790.patch @@ -37,7 +37,7 @@ index e048cb7..d491939 100644 + #define wxDEPRECATED_EXPORT_CORE(msg) \ + __attribute__((visibility("default"))) +#endif - + /* Clang Support diff --git a/matrix.h b/matrix.h @@ -54,6 +54,5 @@ index d18a0d2..a3392b5 100644 { public: wxTransformMatrix(); --- +-- 2.30.2 - diff --git a/build-deps/control b/build-deps/control index 0745b595..be2030a0 100644 --- a/build-deps/control +++ b/build-deps/control @@ -3,6 +3,7 @@ Build-Depends: debhelper (>= 9), base-files (>>8) | mesa-common-dev, base-files (>>8) | libgl1-mesa-dev, libgtk2.0-dev, + libglibmm-2.4-dev, libjsoncpp-dev, libtinyxml-dev, libunarr-dev | base-files (<< 11), diff --git a/build-deps/macos-cache-stamp b/build-deps/macos-cache-stamp index 612bd695..bdd0652e 100644 --- a/build-deps/macos-cache-stamp +++ b/build-deps/macos-cache-stamp @@ -1,4 +1,4 @@ # Any change in this file will cause the macos cache to be invalidated # i. e., that the homebrew dependencies are downloaded and wxwidgets # rebuilt. For example, change the stock 'v1' to 'v2' -v1 +v3 diff --git a/build-deps/macos-deps b/build-deps/macos-deps index 5354c4d9..1170ecc8 100644 --- a/build-deps/macos-deps +++ b/build-deps/macos-deps @@ -2,5 +2,5 @@ cmake gettext libexif -python wget +pipx diff --git a/buildwin/win_deps.bat b/buildwin/win_deps.bat index a9dbfeef..9711dc4a 100644 --- a/buildwin/win_deps.bat +++ b/buildwin/win_deps.bat @@ -1,74 +1,39 @@ +:: :: Install build dependencies. Requires a working choco installation, :: see https://docs.chocolatey.org/en-us/choco/setup. :: -:: Usage: -:: win_deps.bat [wx32] -:: -:: Arguments: -:: wx32: -:: If present install dependencies for building against -:: wxWidgets 3.2. If non-existing or anything but wx32 -:: build using 3.1 -:: Output: -:: cache\wx-config.bat: -:: Script which set wxWidgets_LIB_DIR and wxWidgets_ROOT_DIR -:: :: Initial run will do choco installs requiring administrative :: privileges. :: -:: NOTE: at the very end, this script runs refreshenv. This clears the -:: process's PATH and replaces it with a fresh copy from the -:: registry. This means that any "set PATH=..." is lost for caller. :: Install the pathman tool: https://github.com/therootcompany/pathman :: Fix PATH so it can be used in this script :: - -@echo off - -setlocal enabledelayedexpansion - if not exist "%HomeDrive%%HomePath%\.local\bin\pathman.exe" ( - pushd "%HomeDrive%%HomePath%\.local\bin" - powershell /? >nul 2>&1 - if errorlevel 1 set "PATH=%PATH%;C:\Windows\System32\WindowsPowerShell\v1.0" - curl.exe -sA "windows/10 x86" -o webi-pwsh-install.ps1 ^ - https://webi.ms/packages/_webi/webi-pwsh.ps1 - powershell.exe -ExecutionPolicy Bypass -File webi-pwsh-install.ps1 - webi.bat pathman + pushd "%HomeDrive%%HomePath%" + curl.exe https://webi.ms/pathman | powershell popd ) pathman list > nul 2>&1 -if errorlevel 1 set "PATH=%PATH%;%HomeDrive%\%HomePath%\.local\bin" +if errorlevel 1 set PATH=%PATH%;%HomeDrive%\%HomePath%\.local\bin pathman add %HomeDrive%%HomePath%\.local\bin >nul -git --version > nul 2>&1 -if errorlevel 1 ( - set "GIT_HOME=C:\Program Files\Git" - if not exist "!GIT_HOME!" choco install -y git - pathman add !GIT_HOME!\cmd > nul -) - :: Install choco cmake and add it's persistent user path element :: -cmake --version > nul 2>&1 -if errorlevel 1 ( - set "CMAKE_HOME=C:\Program Files\CMake" - choco install -y cmake - pathman add "!CMAKE_HOME!\bin" > nul - echo Adding !CMAKE_HOME!\bin to path -) +set CMAKE_HOME=C:\Program Files\CMake +if not exist "%CMAKE_HOME%\bin\cmake.exe" choco install --no-progress -y cmake +pathman add "%CMAKE_HOME%\bin" > nul :: Install choco poedit and add it's persistent user path element :: -set "POEDIT_HOME=C:\Program Files (x86)\Poedit\Gettexttools" -if not exist "%POEDIT_HOME%" choco install -y poedit +set POEDIT_HOME=C:\Program Files (x86)\Poedit\Gettexttools +if not exist "%POEDIT_HOME%" choco install --no-progress -y poedit pathman add "%POEDIT_HOME%\bin" > nul :: Update required python stuff :: python --version > nul 2>&1 && python -m ensurepip > nul 2>&1 -if errorlevel 1 choco install -y python +if errorlevel 1 choco install --no-progress -y python python --version python -m ensurepip python -m pip install --upgrade pip @@ -76,44 +41,27 @@ python -m pip install -q setuptools wheel python -m pip install -q cloudsmith-cli python -m pip install -q cryptography -:: :: Install pre-compiled wxWidgets and other DLL; add required paths. :: set SCRIPTDIR=%~dp0 -if "%~1"=="wx32" ( - set "WXWIN=%SCRIPTDIR%..\cache\wxWidgets-3.2.2.1" - set "wxWidgets_ROOT_DIR=!WXWIN!" - set "wxWidgets_LIB_DIR=!WXWIN!\lib\vc14x_dll" -) else ( - set "WXWIN=%SCRIPTDIR%..\cache\wxWidgets-3.2.2.1" - set "wxWidgets_ROOT_DIR=!WXWIN!" - set "wxWidgets_LIB_DIR=!WXWIN!\lib\vc_dll" -) - -if not exist %SCRIPTDIR%\..\cache ( mkdir %SCRIPTDIR%\..\cache ) -set "CONFIG_FILE=%SCRIPTDIR%\..\cache\wx-config.bat" -echo set "wxWidgets_ROOT_DIR=%wxWidgets_ROOT_DIR%" > %CONFIG_FILE% -echo set "wxWidgets_LIB_DIR=%wxWidgets_LIB_DIR%" >> %CONFIG_FILE% - +set WXWIN=%SCRIPTDIR%..\cache\wxWidgets +set wxWidgets_ROOT_DIR=%WXWIN% +set wxWidgets_LIB_DIR=%WXWIN%\lib\vc_dll if not exist "%WXWIN%" ( - wget --version > nul 2>&1 || choco install -y wget - if "%~1"=="wx32" ( - echo Downloading 3.2.2.1 - if not exist %SCRIPTDIR%..\cache\wxWidgets-3.2.2.1 ( - mkdir %SCRIPTDIR%..\cache\wxWidgets-3.2.2.1 - ) - set "GITHUB_DL=https://github.com/wxWidgets/wxWidgets/releases/download" - wget -nv !GITHUB_DL!/v3.2.2.1/wxMSW-3.2.2_vc14x_Dev.7z - 7z x -o%SCRIPTDIR%..\cache\wxWidgets-3.2.2.1 wxMSW-3.2.2_vc14x_Dev.7z - wget -nv !GITHUB_DL!/v3.2.2.1/wxWidgets-3.2.2.1-headers.7z - 7z x -o%SCRIPTDIR%..\cache\wxWidgets-3.2.2.1 wxWidgets-3.2.2.1-headers.7z - ) else ( - echo Downloading 3.1.2 - wget -O wxWidgets-3.1.2.7z -nv ^ - https://download.opencpn.org/s/E2p4nLDzeqx4SdX/download - 7z i > nul 2>&1 || choco install -y 7zip - 7z x wxWidgets-3.1.2.7z -o%WXWIN% - ) + wget --version > nul 2>&1 || choco install --no-progress -y wget + wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxWidgets-3.2.2.1-headers.7z ^ + -O wxWidgetsHeaders.7z + wget -q https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxMSW-3.2.2_vc14x_ReleaseDLL.7z ^ + -O wxWidgetsDLL.7z + wget -q https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxMSW-3.2.2_vc14x_Dev.7z ^ + -O wxWidgetsDev.7z + 7z i > nul 2>&1 || choco install -y 7zip + 7z x -aoa wxWidgetsHeaders.7z -o%WXWIN% + 7z x -aoa wxWidgetsDLL.7z -o%WXWIN% + 7z x -aoa wxWidgetsDev.7z -o%WXWIN% + ren "%WXWIN%\lib\vc14x_dll" vc_dll ) +pathman add "%WXWIN%" > nul +pathman add "%wxWidgets_LIB_DIR%" > nul refreshenv diff --git a/ci/appveyor.bat b/ci/appveyor.bat index b16edf4f..20d4bdf6 100644 --- a/ci/appveyor.bat +++ b/ci/appveyor.bat @@ -15,10 +15,11 @@ call %SCRIPTDIR%..\cache\wx-config.bat echo USING wxWidgets_LIB_DIR: !wxWidgets_LIB_DIR! echo USING wxWidgets_ROOT_DIR: !wxWidgets_ROOT_DIR! -where dumpbin.exe >nul 2>&1 -if errorlevel 1 ( - set "VS_HOME=C:\Program Files\Microsoft Visual Studio\2022" - call "%VS_HOME%\Community\VC\Auxiliary\Build\vcvars32.bat" +if not defined VCINSTALLDIR ( + for /f "tokens=* USEBACKQ" %%p in ( + `"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" ^ + -latest -property installationPath` + ) do call "%%p\Common7\Tools\vsDevCmd.bat" ) if exist build (rmdir /s /q build) diff --git a/ci/check-key-password b/ci/check-key-password index d16cfb3f..19cfb43e 100755 --- a/ci/check-key-password +++ b/ci/check-key-password @@ -3,7 +3,7 @@ # Check if a key encrypted by new-credentials can be decrypted with # a given password. Designed as a test tool # -# Usage: +# Usage: # check-key-password # # key-file: a .enc file created by new-credentials. @@ -50,7 +50,7 @@ def main(): sys.exit(2) with open(sys.argv[1], 'r') as f: encrypted = f.read() - try: + try: decrypt1(encrypted.encode(), sys.argv[2].encode()) except (InvalidToken, InvalidSignature): print("decryption failed") diff --git a/ci/circleci-build-android.sh b/ci/circleci-build-android.sh index 7bb76141..07979579 100755 --- a/ci/circleci-build-android.sh +++ b/ci/circleci-build-android.sh @@ -43,7 +43,7 @@ exec > >(tee $builddir/build.log) 2>&1 # The local container needs to access the cache directory test -d cache || sudo mkdir cache test -w cache || sudo chmod -R go+w cache || : - + sudo apt -q update sudo apt install -q cmake git gettext diff --git a/ci/circleci-build-debian-armhf.sh b/ci/circleci-build-debian-armhf.sh index 1e7030a3..cc51f733 100755 --- a/ci/circleci-build-debian-armhf.sh +++ b/ci/circleci-build-debian-armhf.sh @@ -103,7 +103,7 @@ chown root:root /ci-source git config --global --add safe.directory /ci-source rm -rf build-debian; mkdir build-debian; cd build-debian -cmake -DCMAKE_BUILD_TYPE=Release -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" .. +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" .. make -j $(nproc) VERBOSE=1 tarball ldd app/*/lib/opencpn/*.so @@ -140,7 +140,6 @@ if pyenv versions &>/dev/null; then pyenv versions | tr -d '*' | awk '{print $1}' | tail -1 \ > $HOME/.python-version fi -python3 -m pip install -q --user "urllib3<2.0.0" # See #520 python3 -m pip install -q --user cloudsmith-cli cryptography # python install scripts in ~/.local/bin, teach upload.sh to use in it's PATH: diff --git a/ci/circleci-build-debian-docker.sh b/ci/circleci-build-debian-docker.sh index 3eabbf07..8f34cc7b 100755 --- a/ci/circleci-build-debian-docker.sh +++ b/ci/circleci-build-debian-docker.sh @@ -100,10 +100,12 @@ chown root:root /ci-source git config --global --add safe.directory /ci-source rm -rf build-debian; mkdir build-debian; cd build-debian -cmake -DCMAKE_BUILD_TYPE=Release\ +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" \ -DOCPN_TARGET_TUPLE="@TARGET_TUPLE@" \ .. +git config --global --add safe.directory /ci-source + make -j $(nproc) VERBOSE=1 tarball ldd app/*/lib/opencpn/*.so @@ -111,23 +113,20 @@ cd / setfacl --restore=/ci-source.permissions EOF -if [ -n "$BUILD_WX32" ]; then OCPN_WX_ABI_OPT="-DOCPN_WX_ABI=wx32"; fi - sed -i "s/@TARGET_TUPLE@/$TARGET_TUPLE/" $ci_source/build.sh sed -i "s/@BUILD_WX32@/$BUILD_WX32/" $ci_source/build.sh -#sed -i "s/@OCPN_WX_ABI_OPT@/$OCPN_WX_ABI_OPT/" $ci_source/build.sh # Run script in docker image # docker run \ - -e "CLOUDSMITH_STABLE_REPO=$CLOUDSMITH_STABLE_REPO" \ - -e "CLOUDSMITH_BETA_REPO=$OCPN_BETA_REPO" \ - -e "CLOUDSMITH_UNSTABLE_REPO=$CLOUDSMITH_UNSTABLE_REPO" \ - -e "CIRCLE_BUILD_NUM=$CIRCLE_BUILD_NUM" \ - -e "TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER" \ + -e "CLOUDSMITH_STABLE_REPO" \ + -e "CLOUDSMITH_BETA_REPO" \ + -e "CLOUDSMITH_UNSTABLE_REPO" \ + -e "CIRCLE_BUILD_NUM" \ + -e "TRAVIS_BUILD_NUMBER" \ -v "$ci_source:/ci-source:rw" \ - debian:$OCPN_TARGET /bin/bash -xe /ci-source/build.sh + debian:$OCPN_TARGET /bin/bash -xe /ci-source/build.sh rm -f $ci_source/build.sh @@ -137,7 +136,6 @@ if pyenv versions &>/dev/null; then pyenv versions | tr -d '*' | awk '{print $1}' | tail -1 \ > $HOME/.python-version fi -python3 -m pip install -q --user "urllib3<2.0.0" # See #520 python3 -m pip install -q --user cloudsmith-cli cryptography # python install scripts in ~/.local/bin, teach upload.sh to use in it's PATH: diff --git a/ci/circleci-build-debian.sh b/ci/circleci-build-debian.sh index a4fcffd6..a94b6096 100755 --- a/ci/circleci-build-debian.sh +++ b/ci/circleci-build-debian.sh @@ -83,9 +83,8 @@ mk-build-deps --root-cmd=sudo -ir build-deps/control rm -f *changes *buildinfo if [ -n "$BUILD_WX32" ]; then - remove_wx30; - install_wx32; - OCPN_WX_ABI_OPT="-DOCPN_WX_ABI=wx32" + remove_wx30 + install_wx32 fi if [ -n "$TARGET_TUPLE" ]; then @@ -96,13 +95,12 @@ sudo apt install -q \ python3-pip python3-setuptools python3-dev python3-wheel \ build-essential libssl-dev libffi-dev -python3 -m pip install -q --user "urllib3<2.0.0" # See #520 python3 -m pip install --user --upgrade -q setuptools wheel pip python3 -m pip install --user -q cloudsmith-cli cryptography cmake cd $builddir -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo $OCPN_WX_ABI_OPT $TARGET_OPT .. +cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDbgInfo}" $TARGET_OPT .. make VERBOSE=1 tarball ldd app/*/lib/opencpn/*.so if [ -d /ci-source ]; then diff --git a/ci/circleci-build-flatpak.sh b/ci/circleci-build-flatpak.sh index b0635033..01208d7c 100755 --- a/ci/circleci-build-flatpak.sh +++ b/ci/circleci-build-flatpak.sh @@ -20,6 +20,7 @@ set -x if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi if [ -d /ci-source ]; then cd /ci-source; fi +git config --global protocol.file.allow always git submodule update --init opencpn-libs # Set up build directory and a visible link in / @@ -46,7 +47,7 @@ if [ -n "$CI" ]; then | sudo apt-key add - # Use updated flatpak (#457) - sudo add-apt-repository -y ppa:alexlarsson/flatpak + #sudo add-apt-repository -y ppa:alexlarsson/flatpak sudo apt update # Install or update flatpak and flatpak-builder @@ -73,7 +74,6 @@ cd $builddir # Patch the manifest to use correct branch and runtime unconditionally manifest=$(ls ../flatpak/org.opencpn.OpenCPN.Plugin*yaml) -sed -i '/-DBUILD_TYPE/s/$/ -DOCPN_WX_ABI=wx32/' $manifest # FIXME (leamas) restore beta -> stable when O58 is published sed -i '/^runtime-version/s/:.*/: beta/' $manifest @@ -83,8 +83,9 @@ flatpak remote-add --user --if-not-exists \ flathub https://dl.flathub.org/repo/flathub.flatpakrepo # Configure and build the plugin tarball and metadata. -cmake -DCMAKE_BUILD_TYPE=Release .. -make -j $(nproc) VERBOSE=1 flatpak +cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} .. +# Do not build flatpak in parallel; make becomes unreliable +make -j 1 VERBOSE=1 flatpak # Restore permissions and owner in build tree. if [ -d /ci-source ]; then sudo chown --reference=/ci-source -R . ../cache; fi diff --git a/ci/circleci-build-macos.sh b/ci/circleci-build-macos.sh index c0312a09..20f28301 100755 --- a/ci/circleci-build-macos.sh +++ b/ci/circleci-build-macos.sh @@ -30,7 +30,7 @@ rm -rf build-osx && mkdir build-osx # Create a log file. exec > >(tee build-osx/build.log) 2>&1 -export MACOSX_DEPLOYMENT_TARGET=10.10 +export MACOSX_DEPLOYMENT_TARGET=10.13 # Return latest version of $1, optionally using option $2 pkg_version() { brew list --versions $2 $1 | tail -1 | awk '{print $2}'; } @@ -46,15 +46,21 @@ for pkg in $(sed '/#/d' < $here/../build-deps/macos-deps); do brew link --overwrite $pkg || brew install $pkg done -export OPENSSL_ROOT_DIR='/usr/local/opt/openssl' +#Install prebuilt dependencies +wget -q https://dl.cloudsmith.io/public/nohal/opencpn-plugins/raw/files/macos_deps_universal.tar.xz \ + -O /tmp/macos_deps_universal.tar.xz +sudo tar -C /usr/local -xJf /tmp/macos_deps_universal.tar.xz + +export OPENSSL_ROOT_DIR='/usr/local' # Build and package cd build-osx cmake \ - -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}" \ -DCMAKE_INSTALL_PREFIX= \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \ -DOCPN_TARGET_TUPLE="darwin-wx32;10;x86_64" \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ .. if [[ -z "$CI" ]]; then @@ -68,16 +74,8 @@ fi make VERBOSE=1 tarball || make VERBOSE=1 tarball # Install cloudsmith needed by upload script -python3 -m pip install -q --user cloudsmith-cli - -# Required by git-push -python3 -m pip install -q --user cryptography - -# python3 installs in odd place not on PATH, teach upload.sh to use it: -pyvers=$(python3 --version | awk '{ print $2 }') -pyvers=$(echo $pyvers | sed -E 's/[\.][0-9]+$//') # drop last .z in x.y.z -py_dir=$(ls -d /Users/*/Library/Python/$pyvers/bin) -echo "export PATH=\$PATH:$py_dir" >> ~/.uploadrc +python3 -m pip install cloudsmith-cli +python3 -m pip install cryptography # Create the cached /usr/local archive if [ -n "$CI" ]; then diff --git a/ci/download-wx32.sh b/ci/download-wx32.sh index 312e3b30..f44e3919 100644 --- a/ci/download-wx32.sh +++ b/ci/download-wx32.sh @@ -71,13 +71,13 @@ else cd wxwidgets3.2 git fetch origin master:master git fetch origin pristine-tar:pristine-tar - + echo "Creating the .orig tarball" git checkout pristine-tar pristine-tar checkout $(pristine-tar list | tail -1) mv *xz .. rm * - + echo "Patch and building package" git checkout master patch -p1 < ../patch1.patch @@ -85,11 +85,10 @@ else mk-build-deps --root-cmd=sudo -i -r rm *changes *buildinfo debuild -us -uc - + echo "Installing pkg in /usr/local/pkg" test -d /usr/local/pkg || sudo mkdir /usr/local/pkg sudo cp ../*deb /usr/local/pkg - sudo rm /usr/local/pkg/*dbgsym* + sudo rm /usr/local/pkg/*dbgsym* cd ../... fi - diff --git a/ci/git-push b/ci/git-push index e5582621..56835285 100755 --- a/ci/git-push +++ b/ci/git-push @@ -88,7 +88,7 @@ def private_key_setup(ci, build_deps, user, password): if (os.path.exists(key_path)): print("WARNING: Using key in deprecated location ci/") print("Please move key to build-deps/") - else: + else: key_path = os.path.join(build_deps, user + ".enc") if (os.path.exists(key_path)): with open(key_path, 'r') as f: @@ -209,7 +209,7 @@ def main(): branch = os.environ.get('GIT_BRANCH') branch = branch if branch else "auto" - print("Using repository: " + + print("Using repository: " + ''.join([c + ' ' for c in os.environ.get("GIT_REPO")])) print("Using branch: " + branch) diff --git a/ci/git-push.sh b/ci/git-push.sh index 3fd6b879..ef98e304 100755 --- a/ci/git-push.sh +++ b/ci/git-push.sh @@ -1,11 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash # # Temporary hack to handle .uploadrc and local-build.rc when used for # PYTHONPATH and git-push - +set -x +python3 --version +which python3 +env here=$(cd $(dirname $0); pwd -P) if [ -f ~/.config/local-build.rc ]; then source ~/.config/local-build.rc; fi if [ -f ~/.uploadrc ]; then source ~/.uploadrc; fi +python3 --version cd $here python3 git-push $@ - diff --git a/ci/github-pre-build.sh b/ci/github-pre-build.sh new file mode 100755 index 00000000..de79777d --- /dev/null +++ b/ci/github-pre-build.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# This script is used by GitHub to install the dependencies +# before building wxWidgets but can also be run by hand if necessary (but +# currently it only works for Ubuntu versions used by the CI builds). + +set -e -x + +SUDO=sudo + +case $(uname -s) in + Linux) + if [ -f /etc/apt/sources.list ]; then + # Show information about the repositories and priorities used. + echo 'APT sources used:' + $SUDO grep --no-messages '^[^#]' /etc/apt/sources.list /etc/apt/sources.list.d/* || true + echo '--- End of APT files dump ---' + + run_apt() { + echo "-> Running apt-get $@" + + # Disable some (but not all) output. + $SUDO apt-get -q -o=Dpkg::Use-Pty=0 "$@" + + rc=$? + echo "-> Done with $rc" + + return $rc + } + + run_apt update || echo 'Failed to update packages, but continuing nevertheless.' + + sudo apt-get -qq install devscripts equivs software-properties-common + + sudo mk-build-deps -ir build-deps/control + sudo apt-get -q --allow-unauthenticated install -f + fi + ;; + + Darwin) + # Install packaged dependencies + here=$(cd "$(dirname "$0")"; pwd) + for pkg in $(sed '/#/d' < $here/../build-deps/macos-deps); do + brew list --versions $pkg || brew install $pkg || brew install $pkg || : + brew link --overwrite $pkg || brew install $pkg + done + + pipx install cloudsmith-cli + + if [ ${USE_HOMEBREW:-0} -ne 1 ]; then + # Install the pre-built wxWidgets package + wget -q https://dl.cloudsmith.io/public/nohal/opencpn-plugins/raw/files/macos_deps_universal.tar.xz \ + -O /tmp/macos_deps_universal.tar.xz + sudo tar -C /usr/local -xJf /tmp/macos_deps_universal.tar.xz + else + brew update + brew install wxwidgets + fi + ;; +esac diff --git a/cmake/AndroidLibs.cmake b/cmake/AndroidLibs.cmake index 9f978fd2..b0628b93 100644 --- a/cmake/AndroidLibs.cmake +++ b/cmake/AndroidLibs.cmake @@ -7,11 +7,10 @@ # linkage # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. cmake_minimum_required(VERSION 3.1) @@ -19,64 +18,61 @@ find_package(Gettext REQUIRED) # install() needs to find the cross-compiled library: set_property( - TARGET ${PACKAGE_NAME} - PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib${PACKAGE_NAME}.so -) + TARGET ${PACKAGE_NAME} PROPERTY IMPORTED_LOCATION + ${CMAKE_BINARY_DIR}/lib${PACKAGE_NAME}.so) # Make sure we have downloaded and unpacked master.zip -set( - OCPN_ANDROID_CACHEDIR "${CMAKE_SOURCE_DIR}/cache" - CACHE STRING "Build download area" -) +set(OCPN_ANDROID_CACHEDIR + "${CMAKE_SOURCE_DIR}/cache" + CACHE STRING "Build download area") set(_master_base ${OCPN_ANDROID_CACHEDIR}/OCPNAndroidCommon-master) -if (NOT EXISTS ${OCPN_ANDROID_CACHEDIR}/master.zip) +if(NOT EXISTS ${OCPN_ANDROID_CACHEDIR}/master.zip) file( - DOWNLOAD - https://github.com/bdbcat/OCPNAndroidCommon/archive/master.zip - ${OCPN_ANDROID_CACHEDIR}/master.zip + DOWNLOAD https://github.com/bdbcat/OCPNAndroidCommon/archive/master.zip + ${OCPN_ANDROID_CACHEDIR}/master.zip EXPECTED_HASH - SHA256=a15ebd49fd4e7c0f2d6e99328ed6a9fdb8ed7c8fcaa993cab585fc9d8aab4f56 - SHOW_PROGRESS - ) -endif () -if (NOT EXISTS ${_master_base}) + SHA256=b6359260ecfb44b96c0dd4052e41aac505c9e3c4eb7a798b29c17ddbc3c939b3 + SHOW_PROGRESS) +endif() +if(NOT EXISTS ${_master_base}) message(STATUS "Extracting image (patience, please...)") execute_process( COMMAND ${CMAKE_COMMAND} -E tar -xzf ${OCPN_ANDROID_CACHEDIR}/master.zip - WORKING_DIRECTORY "${OCPN_ANDROID_CACHEDIR}" - ) -endif () + WORKING_DIRECTORY "${OCPN_ANDROID_CACHEDIR}") +endif() # Set up Qt_Build and wxQt_Build -if ("${ARM_ARCH}" STREQUAL "aarch64") - set(_Qt_Build "build_arm64/qtbase") +if("${ARM_ARCH}" STREQUAL "aarch64") + set(_Qt_Build "build_arm64/qtbase") set(_wxQt_Build "build_android_release_64_static_O3") -elseif ("${ARM_ARCH}" STREQUAL "armhf") - set(_Qt_Build "build_arm32_19_O3/qtbase") +elseif("${ARM_ARCH}" STREQUAL "armhf") + set(_Qt_Build "build_arm32_19_O3/qtbase") set(_wxQt_Build "build_android_release_19_static_O3") -else () +else() message(FATAL_ERROR "No valid arm configuration detected.") -endif () -set(Qt_Build ${_Qt_Build} CACHE STRING "Base directory for QT build") -set(wxQt_Build ${_wxQt_Build} CACHE STRING "wxWidgets QT build base directory") +endif() +set(Qt_Build + ${_Qt_Build} + CACHE STRING "Base directory for QT build") +set(wxQt_Build + ${_wxQt_Build} + CACHE STRING "wxWidgets QT build base directory") # Setup directories and libraries -if ("${Qt_Build}" MATCHES "arm64") +if("${Qt_Build}" MATCHES "arm64") file(GLOB _wx_setup - ${_master_base}/wxWidgets/libarm64/wx/include/arm-linux-*-static-* - ) - set(_qt_include ${_master_base}/qt5/build_arm64_O3/qtbase/include) - set(_libgorp ${_master_base}/opencpn/API-117/libarm64/libgorp.so) - set(_qtlibs ${_master_base}/qt5/build_arm64_O3/qtbase/lib) -else () + ${_master_base}/wxWidgets/libarm64/wx/include/arm-linux-*-static-*) + set(_qt_include ${_master_base}/qt5/build_arm64_O3/qtbase/include) + set(_libgorp ${_master_base}/opencpn/API-118/libarm64/libgorp.so) + set(_qtlibs ${_master_base}/qt5/build_arm64_O3/qtbase/lib) +else() file(GLOB _wx_setup - ${_master_base}/wxWidgets/libarmhf/wx/include/arm-linux-*-static-* - ) + ${_master_base}/wxWidgets/libarmhf/wx/include/arm-linux-*-static-*) set(_qt_include ${_master_base}/qt5/build_arm32_19_O3/qtbase/include) - set(_libgorp ${_master_base}/opencpn/API-117/libarmhf/libgorp.so) - set(_qtlibs ${_master_base}/qt5/build_arm32_19_O3/qtbase/lib) -endif () + set(_libgorp ${_master_base}/opencpn/API-118/libarmhf/libgorp.so) + set(_qtlibs ${_master_base}/qt5/build_arm32_19_O3/qtbase/lib) +endif() include_directories( ${_qt_include} @@ -86,9 +82,9 @@ include_directories( ${_qt_include}/QtOpenGL ${_qt_include}/QtTest ${_master_base}/wxWidgets/include/ - ${_wx_setup} -) -target_link_libraries(${PACKAGE_NAME} + ${_wx_setup}) +target_link_libraries( + ${PACKAGE_NAME} ${_libgorp} ${_qtlibs}/libQt5Core.so ${_qtlibs}/libQt5OpenGL.so @@ -96,8 +92,7 @@ target_link_libraries(${PACKAGE_NAME} ${_qtlibs}/libQt5Gui.so ${_qtlibs}/libQt5AndroidExtras.so libGLESv2.so - libEGL.so -) + libEGL.so) add_compile_definitions( __WXQT__ BUILDING_PLUGIN @@ -106,8 +101,7 @@ add_compile_definitions( ocpnUSE_GL USE_ANDROID_GLES2 USE_GLSL - QT_WIDGETS_LINUX -) -if (NOT CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") + QT_WIDGETS_LINUX) +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -s") -endif () +endif() diff --git a/cmake/CmakeSetup.cmake b/cmake/CmakeSetup.cmake index 488d0db5..7486233d 100644 --- a/cmake/CmakeSetup.cmake +++ b/cmake/CmakeSetup.cmake @@ -2,19 +2,17 @@ cmake_minimum_required(VERSION 3.12.0) cmake_policy(SET CMP0042 NEW) -if (POLICY CMP0072) +if(POLICY CMP0072) cmake_policy(SET CMP0072 NEW) -endif () +endif() -if (POLICY CMP0077) +if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) -endif () +endif() # Locations where cmake looks for cmake modules. set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/build ${CMAKE_SOURCE_DIR}/cmake) -if (WIN32) +if(WIN32) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/buildwin) -endif () - - +endif() diff --git a/cmake/ConfigureManifest.cmake b/cmake/ConfigureManifest.cmake index 259bf89f..ee7934b5 100644 --- a/cmake/ConfigureManifest.cmake +++ b/cmake/ConfigureManifest.cmake @@ -4,83 +4,82 @@ # When configuring, process the tokens @plugin_name, @app_id and @include. # # @plugin_name is replaced with the PLUGIN_API_NAME value from Plugin.cmake, -# converted to lowercase. This is expected to be used in the id: line, -# allowing for generic manifests without dependencies. +# converted to lowercase. This is expected to be used in the id: line, allowing +# for generic manifests without dependencies. # # @app_id is replaced with the base part of the id: line, possibly after -# substituting @plugin_name. The part after the last dot is used. This is -# used as installation prefix in generic library snippets . +# substituting @plugin_name. The part after the last dot is used. This is used +# as installation prefix in generic library snippets . # # @include are expected in lines like: # -# - @include libs/glu.yaml +# * @include libs/glu.yaml # # Copy the contents of the filename mentioned after @include into the new -# manifest. -# - Filename is relative to the project top-level directory. -# - The line with @include must start with a '-'. -# - The included file must have a hyphen ('-') at column 0 in the first -# non-comment line. -# - The indentation of the '-' char is added to each line in the included -# file. +# manifest. - Filename is relative to the project top-level directory. - The +# line with @include must start with a '-'. - The included file must have a +# hyphen ('-') at column 0 in the first non-comment line. - The indentation of +# the '-' char is added to each line in the included file. function(configure_manifest manifest new_manifest_path) # Compute generated manifest path and return it in ${new_manifest_path} # - if (${CMAKE_VERSION} VERSION_LESS 3.20) + if(${CMAKE_VERSION} VERSION_LESS 3.20) get_filename_component(manifest_basename ${manifest} NAME) - else () + else() cmake_path(GET manifest FILENAME manifest_basename) - endif () + endif() set(new_manifest ${CMAKE_BINARY_DIR}/${manifest_basename}) - set(${new_manifest_path} ${new_manifest} PARENT_SCOPE) + set(${new_manifest_path} + ${new_manifest} + PARENT_SCOPE) - if (EXISTS ${new_manifest}) - return () - endif () + if(EXISTS ${new_manifest}) + return() + endif() # Determine the overall plugin application id app_id # string(TOLOWER "${PACKAGE_NAME}" pkg_lc_name) file(STRINGS ${manifest} app_id REGEX "^id: ") string(REPLACE @plugin_name ${pkg_lc_name} app_id ${app_id}) - string(REGEX REPLACE ".*[.]" "" app_id "${app_id}") - if ("${app_id}" STREQUAL "") + string(REGEX REPLACE ".*[.]" "" app_id "${app_id}") + if("${app_id}" STREQUAL "") message(FATAL_ERROR "Cannot find a proper id: line in ${manifest}") - endif () + endif() # Process @include # file(STRINGS ${manifest} lines) - foreach (line ${lines}) - if ("${line}" MATCHES "[ \t]*\#") - continue () - endif () - if ("${line}" MATCHES "@include") + foreach(line ${lines}) + if("${line}" MATCHES "[ \t]*\#") + continue() + endif() + if("${line}" MATCHES "@include") string(REGEX REPLACE "-.*" "" indent ${line}) string(REGEX REPLACE ".*@include" "" path "${line}") string(STRIP "${path}" path) set(path ${CMAKE_SOURCE_DIR}/${path}) file(STRINGS ${path} module_lines) - foreach (line_ ${module_lines}) + foreach(line_ ${module_lines}) file(APPEND ${new_manifest} "${indent}${line_}\n") endforeach() - else () + else() file(APPEND ${new_manifest} "${line}\n") - endif () - endforeach () + endif() + endforeach() # Process @plugin_name and @app_id. Drop comments. # file(STRINGS ${new_manifest} lines) file(REMOVE ${new_manifest}) - foreach (line ${lines}) - if ("${line}" MATCHES "[ \t]*\#") - continue () - endif () + foreach(line ${lines}) + if("${line}" MATCHES "[ \t]*\#") + continue() + endif() string(REPLACE @plugin_name ${pkg_lc_name} line ${line}) string(REPLACE @app_id ${app_id} line "${line}") file(APPEND ${new_manifest} "${line}\n") - endforeach () -endfunction () + endforeach() +endfunction() diff --git a/cmake/GetArch.cmake b/cmake/GetArch.cmake index 56a1f4e3..ce08e950 100644 --- a/cmake/GetArch.cmake +++ b/cmake/GetArch.cmake @@ -4,52 +4,53 @@ # Copyright (c) 2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. - -if (COMMAND GetArch) +if(COMMAND GetArch) return() -endif () +endif() # Based on code from nohal -function (GetArch) - if (NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") +function(GetArch) + if(NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") # Return last element from tuple like "Android-armhf;16;armhf" list(GET OCPN_TARGET_TUPLE 2 ARCH) - elseif (NOT WIN32) + elseif(NOT WIN32) # default set(ARCH "x86_64") - if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") - if (CMAKE_SIZEOF_VOID_P MATCHES "8") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") + if(CMAKE_SIZEOF_VOID_P MATCHES "8") set(ARCH "arm64") - else () + else() set(ARCH "armhf") - endif () - else (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") + endif() + else() set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) - endif () - if ("${BUILD_TYPE}" STREQUAL "flatpak") - if (ARCH STREQUAL "arm64") + endif() + if("${BUILD_TYPE}" STREQUAL "flatpak") + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - elseif (EXISTS /etc/redhat-release) - if (ARCH STREQUAL "arm64") + endif() + elseif(EXISTS /etc/redhat-release) + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - elseif (EXISTS /etc/suse-release OR EXISTS /etc/SuSE-release) - if (ARCH STREQUAL "arm64") + endif() + elseif(EXISTS /etc/suse-release OR EXISTS /etc/SuSE-release) + if(ARCH STREQUAL "arm64") set(ARCH "aarch64") - endif () - endif () - else (NOT WIN32) + endif() + endif() + else() # Should really be i386 since we are on win32. However, it's x86_64 for now, # see #2027 set(ARCH "x86_64") - endif () - set(ARCH ${ARCH} PARENT_SCOPE) -endfunction (GetArch) + endif() + set(ARCH + ${ARCH} + PARENT_SCOPE) +endfunction() getarch() diff --git a/cmake/MacosWxwidgets.cmake b/cmake/MacosWxwidgets.cmake index 2bae886e..cfecf086 100644 --- a/cmake/MacosWxwidgets.cmake +++ b/cmake/MacosWxwidgets.cmake @@ -4,97 +4,87 @@ # Copyright (c) 2022 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. cmake_minimum_required(VERSION 3.20.0) set(wx_repo https://github.com/wxWidgets/wxWidgets.git) -set(wx_tag v3.2.1) +set(wx_tag v3.2.2.1) option(IGNORE_SYSTEM_WX "Never use system wxWidgets installation" FALSE) # Check if we have done the wxWidgets build already # -if (DEFINED wx_config) - return () -endif () +if(DEFINED wx_config) + return() +endif() # Check if there is a usable wxwidgets anyway # set(cache_dir ${PROJECT_SOURCE_DIR}/cache) -if (IGNORE_SYSTEM_WX) +if(IGNORE_SYSTEM_WX) set(WX_CONFIG_PROG ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2) -else () +else() find_program( - WX_CONFIG_PROG NAMES wx-config osx_cocoa-unicode-3.2 - HINTS ${PROJECT_SOURCE_DIR}/cache/lib/wx/config /usr/local/lib/wx/config - ) -endif () -if (WX_CONFIG_PROG) + WX_CONFIG_PROG + NAMES wx-config osx_cocoa-unicode-3.2 + HINTS ${PROJECT_SOURCE_DIR}/cache/lib/wx/config /usr/local/lib/wx/config) +endif() +if(WX_CONFIG_PROG) execute_process( COMMAND ${WX_CONFIG_PROG} --version RESULT_VARIABLE wx_status OUTPUT_VARIABLE wx_version - ERROR_FILE /dev/null - COMMAND_ECHO STDOUT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -else () + ERROR_FILE /dev/null COMMAND_ECHO STDOUT + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() set(wx_status 1) -endif () +endif() -if (${wx_status} EQUAL 0) - set(wx_config ${WX_CONFIG_PROG} CACHE FILEPATH "") +if(${wx_status} EQUAL 0) + set(wx_config + ${WX_CONFIG_PROG} + CACHE FILEPATH "") set(ENV{WX_CONFIG} ${WX_CONFIG_PROG}) - if (${wx_version} VERSION_GREATER_EQUAL 3.2) - return () - endif () -endif () + if(${wx_version} VERSION_GREATER_EQUAL 3.2) + return() + endif() +endif() -if (NOT EXISTS ${cache_dir}) +if(NOT EXISTS ${cache_dir}) file(MAKE_DIRECTORY ${cache_dir}) -endif () +endif() # Download sources and get the source directory # include(FetchContent) -FetchContent_Declare(wxwidgets GIT_REPOSITORY ${wx_repo} GIT_TAG ${wx_tag}) +FetchContent_Declare( + wxwidgets + GIT_REPOSITORY ${wx_repo} + GIT_TAG ${wx_tag}) FetchContent_Populate(wxwidgets) FetchContent_GetProperties(wxwidgets SOURCE_DIR wxwidgets_src_dir) +execute_process(COMMAND git submodule update --init 3rdparty/pcre + WORKING_DIRECTORY ${wxwidgets_src_dir}) execute_process( - COMMAND git submodule update --init 3rdparty/pcre - WORKING_DIRECTORY ${wxwidgets_src_dir} -) -execute_process( - COMMAND ./configure - --with-cxx=11 - --with-macosx-version-min=10.10 - --enable-unicode - --with-osx-cocoa - --enable-aui - --disable-debug - --with-opengl - --without-subdirs - --prefix=${cache_dir} - WORKING_DIRECTORY ${wxwidgets_src_dir} -) -math(_nproc ${OCPN_NPROC} * 2) # Assuming two threads/cpu -execute_process( - COMMAND make -j${_nproc} - WORKING_DIRECTORY ${wxwidgets_src_dir} -) -execute_process( - COMMAND sudo make install - WORKING_DIRECTORY ${wxwidgets_src_dir} -) + COMMAND + ./configure --with-cxx=11 --with-macosx-version-min=10.10 --enable-unicode + --with-osx-cocoa --enable-aui --disable-debug --with-opengl + --enable-macosx_arch=arm64,x86_64 --enable-universal_binary=arm64,x86_64 + --without-subdirs --prefix=${cache_dir} + WORKING_DIRECTORY ${wxwidgets_src_dir}) +math(_nproc ${OCPN_NPROC} * 2) # Assuming two threads/cpu +execute_process(COMMAND make -j${_nproc} WORKING_DIRECTORY ${wxwidgets_src_dir}) +execute_process(COMMAND sudo make install + WORKING_DIRECTORY ${wxwidgets_src_dir}) set(wx_config ${cache_dir}/lib/wx/config/osx_cocoa-unicode-3.2) -if (NOT EXISTS ${wx_config}) +if(NOT EXISTS ${wx_config}) message(FATAL_ERROR "Cannot locate wx-config tool at ${wx_config}") -endif () +endif() set(ENV{WX_CONFIG} ${wx_config}) diff --git a/cmake/Metadata.cmake b/cmake/Metadata.cmake index 720169ab..d11e939d 100644 --- a/cmake/Metadata.cmake +++ b/cmake/Metadata.cmake @@ -7,16 +7,16 @@ # all of which with a pkg_ prefix. # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. -#cmake-format: off +# cmake-format: off -if (DEFINED _pkg_metadata_done) +if(DEFINED _pkg_metadata_done) return() -endif () +endif() set(_pkg_metadata_done 1) include(GetArch) @@ -39,65 +39,72 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -if (NOT "$ENV{CIRCLE_BUILD_NUM}" STREQUAL "") +if(NOT "$ENV{CIRCLE_BUILD_NUM}" STREQUAL "") set(_build_id "$ENV{CIRCLE_BUILD_NUM}") set(_pkg_build_info "$ENV{CIRCLE_BUILD_URL}") -elseif (NOT "$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{TRAVIS_BUILD_NUMBER}") set(_pkg_build_info "$ENV{TRAVIS_BUILD_WEB_URL}") -elseif (NOT "$ENV{APPVEYOR_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{APPVEYOR_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{APPVEYOR_BUILD_NUMBER}") string(CONCAT _pkg_build_info "https://ci.appveyor.com/project" "/$ENV{APPVEYOR_ACCOUNT_NAME}/$ENV{APPVEYOR_PROJECT_SLUG}" "/builds/$ENV{APPVEYOR_BUILD_ID}" ) -elseif (NOT "$ENV{DRONE_BUILD_NUMBER}" STREQUAL "") +elseif(NOT "$ENV{DRONE_BUILD_NUMBER}" STREQUAL "") set(_build_id "$ENV{DRONE_BUILD_NUMBER}") set(_pkg_build_info "https://cloud.drone.io/$ENV{DRONE_REPO}/$ENV{DRONE_BUILD_NUMBER}" ) -else () +else() string(TIMESTAMP _build_id "%y%m%d%H%M" UTC) cmake_host_system_information(RESULT _hostname QUERY HOSTNAME) set(_pkg_build_info "${_hostname} - ${_build_id}") -endif () +endif() -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(_gitversion "${_git_hash}") -else () +else() set(_gitversion "${_git_tag}") -endif () +endif() -if (WIN32) +if(WIN32) set(_pkg_arch "win32") -else () - set(_pkg_arch "${ARCH}") -endif () + set(target_arch "${ARCH}") +else() + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + string(REPLACE ";" "-" _pkg_arch "${CMAKE_OSX_ARCHITECTURES}") + set(target_arch "${CMAKE_OSX_ARCHITECTURES}") + else() + set(_pkg_arch "${ARCH}") + set(target_arch "${ARCH}") + endif() +endif() # pkg_build_info: Info about build host (link to log if available). set(pkg_build_info ${_pkg_build_info}) # pkg_repo: Repository to use for upload -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(pkg_repo "$ENV{CLOUDSMITH_UNSTABLE_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_TEST_REPO}) - endif () -else () + endif() +else() string(TOLOWER ${_git_tag} _lc_git_tag) - if (_lc_git_tag MATCHES "beta|rc") + if(_lc_git_tag MATCHES "beta|rc") set(pkg_repo "$ENV{CLOUDSMITH_BETA_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_BETA_REPO}) - endif () - else () + endif() + else() set(pkg_repo "$ENV{CLOUDSMITH_STABLE_REPO}") - if ("${pkg_repo}" STREQUAL "") + if("${pkg_repo}" STREQUAL "") set(pkg_repo ${OCPN_RELEASE_REPO}) - endif () + endif() endif() -endif () +endif() # Make sure repo is displayed even if builders hides environment variables. string(REGEX REPLACE "([a-zA-Z0-9/-])" "\\1 " pkg_repo_display ${pkg_repo}) @@ -106,33 +113,33 @@ message(STATUS "Selected upload repository: ${pkg_repo_display}") # pkg_semver: Complete version including pre-release tag and build info # for untagged builds. set(_pre_rel ${PKG_PRERELEASE}) -if (NOT "${_pre_rel}" STREQUAL "" AND _pre_rel MATCHES "^[^-]") +if(NOT "${_pre_rel}" STREQUAL "" AND _pre_rel MATCHES "^[^-]") string(PREPEND _pre_rel "-") -endif () -if ("${_git_tag}" STREQUAL "") +endif() +if("${_git_tag}" STREQUAL "") set(pkg_semver "${PROJECT_VERSION}${_pre_rel}+${_build_id}.${_gitversion}") -else () +else() set(pkg_semver "${_git_tag}") -endif () +endif() # pkg_displayname: GUI name -if (ARCH MATCHES "arm64|aarch64") - set(_display_arch "-A64") -elseif ("${_pkg_arch}" MATCHES "armhf") +if(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") + set(_display_arch "-universal") +elseif(ARCH MATCHES "arm64|aarch64") + if(NOT CMAKE_OSX_ARCHITECTURES) + set(_display_arch "-A64") + endif() +elseif("${_pkg_arch}" MATCHES "armhf") set(_display_arch "-A32") endif() -if (NOT "${OCPN_WX_ABI}" STREQUAL "") - set(_wx_abi ".${OCPN_WX_ABI}") -endif () - -if ("${_git_tag}" STREQUAL "") +if("${_git_tag}" STREQUAL "") set(pkg_displayname "${PLUGIN_API_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}") -else () +else() set(pkg_displayname "${PLUGIN_API_NAME}-${_git_tag}") -endif () +endif() string(APPEND pkg_displayname - "-${plugin_target}${_wx_abi}${_display_arch}-${plugin_target_version}" + "-${plugin_target}${_display_arch}-${plugin_target_version}" ) # pkg_xmlname: XML metadata basename @@ -141,7 +148,7 @@ set(pkg_xmlname ${pkg_displayname}) # pkg_tarname: Tarball basename string(CONCAT pkg_tarname "${PLUGIN_API_NAME}-${pkg_semver}" - "_${plugin_target}${_wx_abi}-${plugin_target_version}-${_pkg_arch}" + "_${plugin_target}-${plugin_target_version}-${_pkg_arch}" ) # pkg_tarball_url: Tarball location at cloudsmith @@ -154,24 +161,21 @@ string(CONCAT pkg_tarball_url # pkg_python: python command find_program(PY_WRAPPER py) # (at least) appveyor build machines find_program(PYTHON3 python3) -if (PY_WRAPPER) +if(PY_WRAPPER) set(pkg_python ${PY_WRAPPER}) -elseif (PYTHON3) +elseif(PYTHON3) set(pkg_python ${PYTHON3}) -else () +else() set(pkg_python python) -endif () +endif() # pkg_target_arch: os + optional -arch suffix. See: Opencpn bug #2003 -if ("${BUILD_TYPE}" STREQUAL "flatpak") +if("${BUILD_TYPE}" STREQUAL "flatpak") set(pkg_target_arch "flatpak-${ARCH}") - if (NOT "${OCPN_WX_ABI}" STREQUAL "") - set(pkg_target_arch "${pkg_target_arch}-${OCPN_WX_ABI}") - endif () -elseif ("${plugin_target}" MATCHES "ubuntu|raspbian|debian|mingw") +elseif("${plugin_target}" MATCHES "ubuntu|raspbian|debian|mingw|fedora") set(pkg_target_arch "${plugin_target}-${ARCH}") -else () +else() set(pkg_target_arch "${plugin_target}") -endif () +endif() -#cmake-format: on +# cmake-format: on diff --git a/cmake/PluginCompiler.cmake b/cmake/PluginCompiler.cmake index f85b2a4b..0a7d9067 100644 --- a/cmake/PluginCompiler.cmake +++ b/cmake/PluginCompiler.cmake @@ -7,12 +7,12 @@ # Set up the compilation environment, compiler options etc. # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -20,26 +20,25 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(BUILD_SHARED_LIBS TRUE) set(_ocpn_cflags " -Wall -Wno-unused-result -fexceptions") -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") string(APPEND CMAKE_C_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-Bsymbolic") -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Apple is AppleClang +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Apple is AppleClang string(APPEND CMAKE_C_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " ${_ocpn_cflags}") string(APPEND CMAKE_CXX_FLAGS " -Wno-inconsistent-missing-override") string(APPEND CMAKE_CXX_FLAGS " -Wno-potentially-evaluated-expression") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl -undefined dynamic_lookup") -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE) -endif () +endif() -if (UNIX AND NOT APPLE) # linux, see OpenCPN/OpenCPN#1977 - set_target_properties(${PACKAGE_NAME} - PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/.." - ) -endif () +if(UNIX AND NOT APPLE) # linux, see OpenCPN/OpenCPN#1977 + set_target_properties(${PACKAGE_NAME} PROPERTIES INSTALL_RPATH + "$ORIGIN:$ORIGIN/..") +endif() -if (MINGW) +if(MINGW) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L../buildwin") -endif () +endif() diff --git a/cmake/PluginInstall.cmake b/cmake/PluginInstall.cmake index 3c9443df..f0e5fd1b 100644 --- a/cmake/PluginInstall.cmake +++ b/cmake/PluginInstall.cmake @@ -6,49 +6,49 @@ # 2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. include(Metadata) -if (APPLE) +if(APPLE) install( TARGETS ${PACKAGE_NAME} - RUNTIME LIBRARY DESTINATION OpenCPN.app/Contents/PlugIns - ) - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + RUNTIME + LIBRARY DESTINATION OpenCPN.app/Contents/PlugIns) + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install( DIRECTORY data - DESTINATION OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME} - ) - endif () + DESTINATION OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME}) + endif() -elseif (WIN32) +elseif(WIN32) message(STATUS "Install Prefix: ${CMAKE_INSTALL_PREFIX}") - if (CMAKE_CROSSCOMPILING) + if(CMAKE_CROSSCOMPILING) install(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") - else () + else() install(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") - endif () - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + endif() + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install(DIRECTORY data DESTINATION "plugins/${PACKAGE_NAME}") - endif () + endif() -elseif (UNIX) +elseif(UNIX) install( TARGETS ${PACKAGE_NAME} - RUNTIME LIBRARY DESTINATION lib/opencpn - ) - if (EXISTS ${PROJECT_SOURCE_DIR}/data) + RUNTIME + LIBRARY DESTINATION lib/opencpn) + if(EXISTS ${PROJECT_SOURCE_DIR}/data) install(DIRECTORY data DESTINATION share/opencpn/plugins/${PACKAGE_NAME}) - endif () -endif () + endif() +endif() # Hardcoded, absolute destination for tarball generation -if (${BUILD_TYPE} STREQUAL "tarball" OR ${BUILD_TYPE} STREQUAL "flatpak") - install(CODE " +if(${BUILD_TYPE} STREQUAL "tarball" OR ${BUILD_TYPE} STREQUAL "flatpak") + install( + CODE " configure_file( ${CMAKE_BINARY_DIR}/${pkg_displayname}.xml.in ${CMAKE_BINARY_DIR}/app/files/metadata.xml @@ -59,34 +59,36 @@ endif() # On macos, fix paths which points to the build environment, make sure they # refers to runtime locations -if (${BUILD_TYPE} STREQUAL "tarball" AND APPLE) - install(CODE - "execute_process( +if(${BUILD_TYPE} STREQUAL "tarball" AND APPLE) + install(CODE "execute_process( COMMAND bash -c ${PROJECT_SOURCE_DIR}/cmake/fix-macos-libs.sh - )" - ) + )") endif() -if (CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel") - if (APPLE) +if(CMAKE_BUILD_TYPE MATCHES "Release|MinSizeRel") + if(APPLE) set(_striplib OpenCPN.app/Contents/PlugIns/lib${PACKAGE_NAME}.dylib) - elseif (MINGW) + elseif(MINGW) set(_striplib plugins/lib${PACKAGE_NAME}.dll) - elseif (UNIX AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{FLATPAK_ID}) + elseif( + UNIX + AND NOT CMAKE_CROSSCOMPILING + AND NOT DEFINED ENV{FLATPAK_ID}) # Plain, native linux set(_striplib lib/opencpn/lib${PACKAGE_NAME}.so) - endif () - if (BUILD_TYPE STREQUAL "tarball" AND DEFINED _striplib) + endif() + if(BUILD_TYPE STREQUAL "tarball" AND DEFINED _striplib) find_program(STRIP_UTIL NAMES strip REQUIRED) - if (APPLE) + if(APPLE) set(STRIP_UTIL "${STRIP_UTIL} -x") - endif () + endif() install(CODE "message(STATUS \"Stripping ${_striplib}\")") - install(CODE " + install( + CODE " execute_process( WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${STRIP_UTIL} app/files/${_striplib} ) ") - endif () -endif () + endif() +endif() diff --git a/cmake/PluginLibs.cmake b/cmake/PluginLibs.cmake index 0a45b516..5bc809cd 100644 --- a/cmake/PluginLibs.cmake +++ b/cmake/PluginLibs.cmake @@ -6,25 +6,26 @@ # Find and link general libraries to use: gettext, wxWidgets and OpenGL # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. find_package(Gettext REQUIRED) # # Windows environment check # -set(_bad_win_env_msg [=[ +set(_bad_win_env_msg + [=[ %WXWIN% is not present in environment, win_deps.bat has not been run. Build might work, but most likely fail when not finding wxWidgets. Run buildwin\win_deps.bat or set %WXWIN% to mute this message. ]=]) -if (WIN32 AND NOT DEFINED ENV{WXWIN}) +if(WIN32 AND NOT DEFINED ENV{WXWIN}) message(WARNING ${_bad_win_env_msg}) -endif () +endif() # # OpenGL @@ -33,34 +34,33 @@ endif () set(OpenGL_GL_PREFERENCE "LEGACY") find_package(OpenGL) -if (TARGET OpenGL::GL) +if(TARGET OpenGL::GL) target_link_libraries(${PACKAGE_NAME} OpenGL::GL) -else () +else() message(WARNING "Cannot locate usable OpenGL libs and headers.") -endif () -if (NOT OPENGL_GLU_FOUND) +endif() +if(NOT OPENGL_GLU_FOUND) message(WARNING "Cannot find OpenGL GLU extension.") -endif () -if (APPLE) - # As of 3.19.2, cmake's FindOpenGL does not link to the directory - # containing gl.h. cmake bug? Intended due to missing subdir GL/gl.h? +endif() +if(APPLE) + # As of 3.19.2, cmake's FindOpenGL does not link to the directory containing + # gl.h. cmake bug? Intended due to missing subdir GL/gl.h? find_path(GL_H_DIR NAMES gl.h) - if (GL_H_DIR) + if(GL_H_DIR) target_include_directories(${PACKAGE_NAME} PRIVATE "${GL_H_DIR}") - else () + else() message(WARNING "Cannot locate OpenGL header file gl.h") - endif () -endif () -if (WIN32) - if (EXISTS "${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") + endif() +endif() +if(WIN32) + if(EXISTS "${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") add_subdirectory("${PROJECT_SOURCE_DIR}/libs/WindowsHeaders") target_link_libraries(${PACKAGE_NAME} windows::headers) - else () - message(STATUS - "WARNING: WindowsHeaders library is missing, OpenGL unavailable" - ) - endif () -endif () + else() + message( + STATUS "WARNING: WindowsHeaders library is missing, OpenGL unavailable") + endif() +endif() # # wxWidgets @@ -70,10 +70,18 @@ set(wxWidgets_USE_UNICODE ON) set(wxWidgets_USE_UNIVERSAL OFF) set(wxWidgets_USE_STATIC OFF) -set(WX_COMPONENTS base core net xml html adv stc aui) -if (TARGET OpenGL::OpenGL OR TARGET OpenGL::GL) +set(WX_COMPONENTS + base + core + net + xml + html + adv + stc + aui) +if(TARGET OpenGL::OpenGL OR TARGET OpenGL::GL) list(APPEND WX_COMPONENTS gl) -endif () +endif() find_package(wxWidgets REQUIRED ${WX_COMPONENTS}) include(${wxWidgets_USE_FILE}) diff --git a/cmake/PluginLocalization.cmake b/cmake/PluginLocalization.cmake index b81f1a67..8ec323fd 100644 --- a/cmake/PluginLocalization.cmake +++ b/cmake/PluginLocalization.cmake @@ -5,17 +5,16 @@ # License: GPLv3+ # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext) string(REPLACE "_pi" "" I18N_NAME ${PACKAGE_NAME}) -if (GETTEXT_XGETTEXT_EXECUTABLE) +if(GETTEXT_XGETTEXT_EXECUTABLE) add_custom_command( OUTPUT po/${PACKAGE_NAME}.pot.dummy COMMAND @@ -25,20 +24,18 @@ if (GETTEXT_XGETTEXT_EXECUTABLE) --files-from=${CMAKE_CURRENT_SOURCE_DIR}/po/POTFILES.in DEPENDS po/POTFILES.in po/${PACKAGE_NAME}.pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "${I18N_NAME}-pot-update [${PACKAGE_NAME}]: Generated pot file." - ) + COMMENT "${I18N_NAME}-pot-update [${PACKAGE_NAME}]: Generated pot file.") add_custom_target( ${I18N_NAME}-pot-update COMMENT "[${PACKAGE_NAME}]-pot-update: Done." - DEPENDS po/${PACKAGE_NAME}.pot.dummy - ) -endif (GETTEXT_XGETTEXT_EXECUTABLE) + DEPENDS po/${PACKAGE_NAME}.pot.dummy) +endif() -macro (GETTEXT_UPDATE_PO _potFile) +macro(GETTEXT_UPDATE_PO _potFile) set(_poFiles ${_potFile}) get_filename_component(_absPotFile ${_potFile} ABSOLUTE) - foreach (_currentPoFile ${ARGN}) + foreach(_currentPoFile ${ARGN}) get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) get_filename_component(_poBasename ${_absFile} NAME_WE) @@ -47,26 +44,24 @@ macro (GETTEXT_UPDATE_PO _potFile) COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --width=80 --strict --quiet --update --backup=none --no-location -s ${_absFile} ${_absPotFile} DEPENDS ${_absPotFile} ${_absFile} - COMMENT "${I18N_NAME}-po-update [${_poBasename}]: Updated po file." - ) + COMMENT "${I18N_NAME}-po-update [${_poBasename}]: Updated po file.") set(_poFiles ${_poFiles} ${_absFile}.dummy) - endforeach (_currentPoFile) + endforeach() add_custom_target( ${I18N_NAME}-po-update COMMENT "[${PACKAGE_NAME}]-po-update: Done." - DEPENDS ${_poFiles} - ) -endmacro (GETTEXT_UPDATE_PO) + DEPENDS ${_poFiles}) +endmacro() -if (GETTEXT_MSGMERGE_EXECUTABLE) +if(GETTEXT_MSGMERGE_EXECUTABLE) file(GLOB PACKAGE_PO_FILES po/*.po) gettext_update_po(po/${PACKAGE_NAME}.pot ${PACKAGE_PO_FILES}) -endif (GETTEXT_MSGMERGE_EXECUTABLE) +endif() set(_gmoFiles) -macro (GETTEXT_BUILD_MO) - foreach (_poFile ${ARGN}) +macro(GETTEXT_BUILD_MO) + foreach(_poFile ${ARGN}) get_filename_component(_absFile ${_poFile} ABSOLUTE) get_filename_component(_poBasename ${_absFile} NAME_WE) set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_poBasename}.mo) @@ -77,34 +72,30 @@ macro (GETTEXT_BUILD_MO) COMMAND ${CMAKE_COMMAND} -E copy ${_gmoFile} "Resources/${_poBasename}.lproj/opencpn-${PACKAGE_NAME}.mo" DEPENDS ${_absFile} - COMMENT "${I18N_NAME}-i18n [${_poBasename}]: Created mo file." - ) - if (APPLE) + COMMENT "${I18N_NAME}-i18n [${_poBasename}]: Created mo file.") + if(APPLE) install( FILES ${_gmoFile} DESTINATION OpenCPN.app/Contents/Resources/${_poBasename}.lproj - RENAME opencpn-${PACKAGE_NAME}.mo - ) - else (APPLE) + RENAME opencpn-${PACKAGE_NAME}.mo) + else() install( FILES ${_gmoFile} DESTINATION share/locale/${_poBasename}/LC_MESSAGES - RENAME opencpn-${PACKAGE_NAME}.mo - ) - endif (APPLE) + RENAME opencpn-${PACKAGE_NAME}.mo) + endif() set(_gmoFiles ${_gmoFiles} ${_gmoFile}) - endforeach (_poFile) -endmacro (GETTEXT_BUILD_MO) + endforeach() +endmacro() -if (GETTEXT_MSGFMT_EXECUTABLE) +if(GETTEXT_MSGFMT_EXECUTABLE) file(GLOB PACKAGE_PO_FILES po/*.po) gettext_build_mo(${PACKAGE_PO_FILES}) add_custom_target( ${I18N_NAME}-i18n COMMENT "${PACKAGE_NAME}-i18n: Done." - DEPENDS ${_gmoFiles} - ) + DEPENDS ${_gmoFiles}) add_dependencies(${PACKAGE_NAME} ${I18N_NAME}-i18n) - add_dependencies( tarball ${I18N_NAME}-i18n) -endif (GETTEXT_MSGFMT_EXECUTABLE) + add_dependencies(tarball ${I18N_NAME}-i18n) +endif() diff --git a/cmake/PluginOptions.cmake b/cmake/PluginOptions.cmake index 4aff0dee..9438c717 100644 --- a/cmake/PluginOptions.cmake +++ b/cmake/PluginOptions.cmake @@ -1,18 +1,17 @@ # ~~~ -# Summary: Set up default plugin build options +# Summary: Set up default plugin build options # License: GPLv3+ # Copyright (c) 2020-2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -if (DEFINED _default_build_type) - return () -endif () +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +if(DEFINED _default_build_type) + return() +endif() # Set a default build type if none was specified # https://blog.kitware.com/cmake-and-the-default-build-type/ @@ -20,66 +19,68 @@ set(_default_build_type "Release") if(EXISTS "${CMAKE_SOURCE_DIR}/.git") set(_default_build_type "Debug") endif() - + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS - "Setting build type to '${_default_build_type}' as none was specified." - ) - set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE - STRING "Choose the type of build." FORCE) + message( + STATUS + "Setting build type to '${_default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE + "${_default_build_type}" + CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") endif() - # Set up option NPROC: Number of processors used when compiling. -if (DEFINED ENV{CMAKE_BUILD_PARALLEL_LEVEL}) +if(DEFINED ENV{CMAKE_BUILD_PARALLEL_LEVEL}) set(_nproc $ENV{CMAKE_BUILD_PARALLEL_LEVEL}) -else () - if (WIN32) +else() + if(WIN32) + # cmake-lint: disable=C0103 set(_nproc_cmd - cmd /C if defined NUMBER_OF_PROCESSORS (echo %NUMBER_OF_PROCESSORS%) - else (echo 1) - ) + cmd + /C + if + defined + NUMBER_OF_PROCESSORS + (echo %NUMBER_OF_PROCESSORS%) + else + (echo 1)) - elseif (APPLE) + elseif(APPLE) set(_nproc_cmd sysctl -n hw.physicalcpu) - else () + else() set(_nproc_cmd nproc) - endif () + endif() execute_process( COMMAND ${_nproc_cmd} OUTPUT_VARIABLE _nproc RESULT_VARIABLE _status - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if (NOT "${_status}" STREQUAL "0") + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT "${_status}" STREQUAL "0") set(_nproc 1) - message( - STATUS "Cannot probe for processor count using \"${_nproc_cmd}\"" - ) - endif () -endif () -set(OCPN_NPROC ${_nproc} - CACHE STRING "Number of processors used to compile [${_nproc}]" -) + message(STATUS "Cannot probe for processor count using \"${_nproc_cmd}\"") + endif() +endif() +set(OCPN_NPROC + ${_nproc} + CACHE STRING "Number of processors used to compile [${_nproc}]") message(STATUS "Build uses ${OCPN_NPROC} processors") - # Set up OCPN_TARGET_TUPLE and update QT_ANDROID accordingly -set(OCPN_TARGET_TUPLE "" CACHE STRING - "Target spec: \"platform;version;arch\"" -) +set(OCPN_TARGET_TUPLE + "" + CACHE STRING "Target spec: \"platform;version;arch\"") string(TOLOWER "${OCPN_TARGET_TUPLE}" _lc_target) -if ("${_lc_target}" MATCHES "android*") +if("${_lc_target}" MATCHES "android*") set(QT_ANDROID ON) - if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) - message(FATAL_ERROR - "Android targets requires using a toolchain file. See INSTALL.md" - ) - endif () -else () + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + message( + FATAL_ERROR + "Android targets requires using a toolchain file. See INSTALL.md") + endif() +else() set(QT_ANDROID OFF) -endif () +endif() diff --git a/cmake/PluginSetup.cmake b/cmake/PluginSetup.cmake index 5532f09c..aa776036 100644 --- a/cmake/PluginSetup.cmake +++ b/cmake/PluginSetup.cmake @@ -4,94 +4,89 @@ # Copyright (c) 2020-2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +if(DEFINED plugin_target) + return() +endif() -if (DEFINED plugin_target) - return () -endif () - -if (NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") +if(NOT "${OCPN_TARGET_TUPLE}" STREQUAL "") list(GET OCPN_TARGET_TUPLE 0 plugin_target) list(GET OCPN_TARGET_TUPLE 1 plugin_target_version) -elseif ("${BUILD_TYPE}" STREQUAL "flatpak") +elseif("${BUILD_TYPE}" STREQUAL "flatpak") set(plugin_target "flatpak") file(GLOB manifest_path "${PROJECT_SOURCE_DIR}/flatpak/org.opencpn.*.yaml") file(READ ${manifest_path} manifest) string(REPLACE "\n" ";" manifest_lines "${manifest}") - foreach (_line ${manifest_lines}) - if (${_line} MATCHES "org.freedesktop.Sdk") + foreach(_line ${manifest_lines}) + if(${_line} MATCHES "org.freedesktop.Sdk") string(REGEX REPLACE ".*//" "" plugin_target_version "${_line}") - endif () - endforeach () - message(STATUS "Building for flatpak runtime ${plugin_target_version}") -elseif (MINGW) + endif() + endforeach() + message(STATUS "Building for flatpak runtime ${plugin_target_version}") +elseif(MINGW) set(plugin_target "mingw") - if (CMAKE_SYSTEM_VERSION) + if(CMAKE_SYSTEM_VERSION) set(plugin_target_version ${CMAKE_SYSTEM_VERSION}) - else () + else() set(plugin_target_version 10) - endif () -elseif (MSVC) + endif() +elseif(MSVC) set(plugin_target "msvc-wx32") - if (CMAKE_SYSTEM_VERSION) + if(CMAKE_SYSTEM_VERSION) set(plugin_target_version ${CMAKE_SYSTEM_VERSION}) - elseif (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + elseif(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) set(plugin_target_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) - else () + else() set(plugin_target_version 10) - endif () -elseif (APPLE) + endif() +elseif(APPLE) set(plugin_target "darwin-wx32") set(plugin_target_version "10.13.6") -elseif (UNIX) +elseif(UNIX) # Some linux dist: execute_process( COMMAND "lsb_release" "-is" OUTPUT_VARIABLE plugin_target - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND "lsb_release" "-rs" OUTPUT_VARIABLE plugin_target_version - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -else () + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() set(plugin_target "unknown") set(plugin_target_version 1) -endif () +endif() string(STRIP "${plugin_target}" plugin_target) string(TOLOWER "${plugin_target}" plugin_target) string(STRIP "${plugin_target_version}" plugin_target_version) string(TOLOWER "${plugin_target_version}" plugin_target_version) -if (plugin_target STREQUAL "ubuntu") - if (DEFINED wxWidgets_CONFIG_EXECUTABLE) +if(plugin_target STREQUAL "ubuntu") + if(DEFINED wxWidgets_CONFIG_EXECUTABLE) set(_WX_CONFIG_PROG ${wxWidgets_CONFIG_EXECUTABLE}) - else () - find_program(_WX_CONFIG_PROG NAMES $ENV{WX_CONFIG} wx-config ) - endif () - if (_WX_CONFIG_PROG) + else() + find_program(_WX_CONFIG_PROG NAMES $ENV{WX_CONFIG} wx-config) + endif() + if(_WX_CONFIG_PROG) execute_process( COMMAND ${_WX_CONFIG_PROG} --selected-config OUTPUT_VARIABLE _WX_SELECTED_CONFIG - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if (_WX_SELECTED_CONFIG MATCHES gtk3) - if (${plugin_target_version} VERSION_LESS 22.04) + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_WX_SELECTED_CONFIG MATCHES gtk3) + if(${plugin_target_version} VERSION_LESS 22.04) set(plugin_target ubuntu-gtk3) - endif () - endif () - else () + endif() + endif() + else() message(WARNING "Cannot locate wx-config utility") - endif () -endif () + endif() +endif() string(CONCAT msg "Building for target-release " - "${plugin_target}-${plugin_target_version}" -) + "${plugin_target}-${plugin_target_version}") message(STATUS "${msg}") diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 47080ebf..2d9a3559 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -7,60 +7,69 @@ # with helper targets. Also sets up the default target. # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. - - - -if (TARGET tarball-build) +if(TARGET tarball-build) return() -endif () +endif() include(Metadata) -if (UNIX AND NOT APPLE AND NOT QT_ANDROID) +if(UNIX + AND NOT APPLE + AND NOT QT_ANDROID) set(_LINUX ON) -else () +else() set(_LINUX OFF) -endif () +endif() -if (WIN32) - if (CMAKE_VERSION VERSION_LESS 3.16) +if(WIN32) + if(CMAKE_VERSION VERSION_LESS 3.16) message(WARNING "windows requires cmake version 3.16 or higher") - endif () -endif () + endif() +endif() # Set up _build_cmd set(_build_cmd - cmake --build ${CMAKE_BINARY_DIR} --parallel ${OCPN_NPROC} --config $ -) + cmake + --build + ${CMAKE_BINARY_DIR} + --parallel + ${OCPN_NPROC} + --config + $) # Set up _build_target_cmd and _install_cmd -if (CMAKE_VERSION VERSION_LESS 3.16) +if(CMAKE_VERSION VERSION_LESS 3.16) set(_build_target_cmd make) set(_install_cmd make install) -else () +else() set(_build_target_cmd - cmake --build ${CMAKE_BINARY_DIR} --parallel ${OCPN_NPROC} - --config $ --target - ) + cmake + --build + ${CMAKE_BINARY_DIR} + --parallel + ${OCPN_NPROC} + --config + $ + --target) set(_install_cmd cmake --install ${CMAKE_BINARY_DIR} --config $) -endif () +endif() # Command to remove directory -if (CMAKE_VERSION VERSION_LESS 3.17) +if(CMAKE_VERSION VERSION_LESS 3.17) set(_rmdir_cmd "remove_directory") -else () - set(_rmdir_cmd "rm -rf" ) -endif () - +else() + set(_rmdir_cmd "rm -rf") +endif() # Cmake batch file to compute and patch metadata checksum # -set(_cs_script " +set(_cs_script + " execute_process( COMMAND cmake -E sha256sum ${CMAKE_BINARY_DIR}/${pkg_tarname}.tar.gz OUTPUT_FILE ${CMAKE_BINARY_DIR}/${pkg_tarname}.sha256 @@ -75,8 +84,9 @@ set(_cs_script " ") file(WRITE "${CMAKE_BINARY_DIR}/checksum.cmake" ${_cs_script}) -function (create_finish_script) - set(_finish_script " +function(create_finish_script) + set(_finish_script + " execute_process( COMMAND cmake -E ${_rmdir_cmd} app/${pkg_displayname} ) @@ -95,28 +105,25 @@ function (create_finish_script) message(STATUS \"Computing checksum in ${pkg_xmlname}.xml\") ") file(WRITE "${CMAKE_BINARY_DIR}/finish_tarball.cmake" "${_finish_script}") -endfunction () +endfunction() -function (android_target) - if ("${ARM_ARCH}" STREQUAL "aarch64") +function(android_target) + if("${ARM_ARCH}" STREQUAL "aarch64") set(OCPN_TARGET_TUPLE "'android-arm64\;16\;arm64'") - else () + else() set(OCPN_TARGET_TUPLE "'android-armhf\;16\;armhf'") - endif () + endif() add_custom_command( OUTPUT android-conf-stamp COMMAND cmake -E touch android-conf-stamp - COMMAND cmake - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/app/files + COMMAND + cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/app/files -DBUILD_TYPE:STRING=tarball - -DOCPN_TARGET_TUPLE:STRING=${OCPN_TARGET_TUPLE} - $ENV{CMAKE_BUILD_OPTS} - ${CMAKE_BINARY_DIR} - ) + -DOCPN_TARGET_TUPLE:STRING=${OCPN_TARGET_TUPLE} $ENV{CMAKE_BUILD_OPTS} + ${CMAKE_BINARY_DIR}) add_custom_target(android-build DEPENDS android-conf-stamp) - add_custom_command( - TARGET android-build COMMAND ${_build_target_cmd} ${PKG_NAME} - ) + add_custom_command(TARGET android-build COMMAND ${_build_target_cmd} + ${PKG_NAME}) add_custom_target(android-install) add_custom_command(TARGET android-install COMMAND ${_install_cmd}) @@ -125,32 +132,27 @@ function (android_target) add_custom_command( TARGET android-finish COMMAND cmake -P ${CMAKE_BINARY_DIR}/finish_tarball.cmake - VERBATIM - ) + VERBATIM) add_custom_target(android) add_dependencies(android android-finish) add_dependencies(android-finish android-install) add_dependencies(android-install android-build) -endfunction () +endfunction() -function (tarball_target) +function(tarball_target) # tarball target setup # add_custom_command( OUTPUT tarball-conf-stamp COMMAND cmake -E touch tarball-conf-stamp - COMMAND cmake - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/app/files - -DBUILD_TYPE:STRING=tarball - $ENV{CMAKE_BUILD_OPTS} - ${CMAKE_BINARY_DIR} - ) + COMMAND + cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/app/files + -DBUILD_TYPE:STRING=tarball $ENV{CMAKE_BUILD_OPTS} ${CMAKE_BINARY_DIR}) add_custom_target(tarball-build DEPENDS tarball-conf-stamp) - add_custom_command( - TARGET tarball-build COMMAND ${_build_target_cmd} ${PKG_NAME} - ) + add_custom_command(TARGET tarball-build COMMAND ${_build_target_cmd} + ${PKG_NAME}) add_custom_target(tarball-install) add_custom_command(TARGET tarball-install COMMAND ${_install_cmd}) @@ -158,31 +160,28 @@ function (tarball_target) create_finish_script() add_custom_target(tarball-finish) add_custom_command( - TARGET tarball-finish # Compute checksum + TARGET tarball-finish # Compute checksum COMMAND cmake -P ${CMAKE_BINARY_DIR}/finish_tarball.cmake - VERBATIM - ) + VERBATIM) add_dependencies(tarball-install tarball-build) add_dependencies(tarball-finish tarball-install) add_custom_target(tarball) add_dependencies(tarball tarball-finish) -endfunction () +endfunction() -function (flatpak_target manifest) +function(flatpak_target manifest) add_custom_target(flatpak-conf) add_custom_command( TARGET flatpak-conf - COMMAND cmake - -DBUILD_TYPE:STRING=flatpak - -Uplugin_target - $ENV{CMAKE_BUILD_OPTS} - ${CMAKE_BINARY_DIR} - ) + COMMAND cmake -DBUILD_TYPE:STRING=flatpak -Uplugin_target + $ENV{CMAKE_BUILD_OPTS} ${CMAKE_BINARY_DIR}) # Script used to copy out files from the flatpak sandbox - file(WRITE ${CMAKE_BINARY_DIR}/copy_out [=[ + file( + WRITE ${CMAKE_BINARY_DIR}/copy_out + [=[ appdir=$(find /run/build -maxdepth 3 -iname $1) appdir=$(ls -t $appdir) # Sort entries if there is more than one appdir=${appdir%% *} # Pick first entry @@ -190,7 +189,8 @@ function (flatpak_target manifest) cp -ar $appdir/app $2 ]=]) - set(_fp_script " + set(_fp_script + " execute_process( COMMAND flatpak-builder --force-clean --keep-build-dirs @@ -201,21 +201,21 @@ function (flatpak_target manifest) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND flatpak-builder --run app ${manifest} - bash copy_out lib${PACKAGE_NAME}.so ${CMAKE_BINARY_DIR} + bash copy_out lib${PACKAGE_NAME}.so ${CMAKE_BINARY_DIR} ) - if (NOT EXISTS app/files/lib/opencpn/lib${PACKAGE_NAME}.so) + if(NOT EXISTS app/files/lib/opencpn/lib${PACKAGE_NAME}.so) message(FATAL_ERROR \"Cannot find generated file lib${PACKAGE_NAME}.so\") - endif () + endif() execute_process( COMMAND bash -c \"sed -e '/@checksum@/d' \ < ${pkg_xmlname}.xml.in > app/files/metadata.xml\" ) - if (${CMAKE_BUILD_TYPE} MATCHES Release|MinSizeRel) + if(${CMAKE_BUILD_TYPE} MATCHES Release|MinSizeRel) message(STATUS \"Stripping app/files/lib/opencpn/lib${PACKAGE_NAME}.so\") execute_process( COMMAND strip app/files/lib/opencpn/lib${PACKAGE_NAME}.so ) - endif () + endif() execute_process( WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/app COMMAND mv -fT files ${pkg_displayname} @@ -237,26 +237,24 @@ function (flatpak_target manifest) add_custom_command( TARGET flatpak COMMAND cmake -P ${CMAKE_BINARY_DIR}/build_flatpak.cmake - VERBATIM - ) + VERBATIM) add_dependencies(flatpak flatpak-conf) -endfunction () +endfunction() -function (create_targets manifest) - # Add the primary build targets android, flatpak and tarball together - # with support targets. Parameters: - # - manifest: Flatpak build manifest +function(create_targets manifest) + # Add the primary build targets android, flatpak and tarball together with + # support targets. Parameters: - manifest: Flatpak build manifest - if (BUILD_TYPE STREQUAL "pkg") + if(BUILD_TYPE STREQUAL "pkg") message(FATAL_ERROR "Legacy package generation is not supported.") - endif () + endif() tarball_target() flatpak_target(${manifest}) android_target() add_custom_target(default ALL) - if ("${ARM_ARCH}" STREQUAL "") + if("${ARM_ARCH}" STREQUAL "") add_dependencies(default tarball) - else () + else() add_dependencies(default android) - endif () -endfunction () + endif() +endfunction() diff --git a/cmake/TemplateVersion b/cmake/TemplateVersion index daff6e77..82fefbe3 100644 --- a/cmake/TemplateVersion +++ b/cmake/TemplateVersion @@ -1,4 +1,4 @@ # Created by update-templates -date: 2023-07-28 18:25 UTC -commit: aec5cb81 -tags: sd3.2.4 +date: 2023-04-08 15:29 UTC +commit: 5f15a0c4 +tags: sd3.2.3 diff --git a/cmake/android-aarch64-toolchain.cmake b/cmake/android-aarch64-toolchain.cmake index 2ee7b34c..ccc45365 100644 --- a/cmake/android-aarch64-toolchain.cmake +++ b/cmake/android-aarch64-toolchain.cmake @@ -5,19 +5,20 @@ # ~~~ # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. set(CMAKE_SYSTEM_NAME Android) set(CMAKE_SYSTEM_VERSION 21) set(CMAKE_ANDROID_ARCH_ABI arm64-v8a) -if (DEFINED ENV{NDK_HOME}) +if(DEFINED ENV{NDK_HOME}) set(CMAKE_ANDROID_NDK $ENV{NDK_HOME}) -else () +else() set(CMAKE_ANDROID_NDK /opt/android/ndk) -endif () +endif() -set(ARM_ARCH aarch64 CACHE STRING "Selected arm architecture" FORCE) +set(ARM_ARCH + aarch64 + CACHE STRING "Selected arm architecture" FORCE) diff --git a/cmake/android-armhf-toolchain.cmake b/cmake/android-armhf-toolchain.cmake index 9830fd21..47f82216 100644 --- a/cmake/android-armhf-toolchain.cmake +++ b/cmake/android-armhf-toolchain.cmake @@ -4,17 +4,19 @@ # Copyright (c) 2021 Alec Leamas # ~~~ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. set(CMAKE_SYSTEM_NAME Android) set(CMAKE_SYSTEM_VERSION 16) set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) -if (DEFINED ENV{NDK_HOME}) +if(DEFINED ENV{NDK_HOME}) set(CMAKE_ANDROID_NDK $ENV{NDK_HOME}) -else () +else() set(CMAKE_ANDROID_NDK /opt/android/ndk) -endif () -set(ARM_ARCH armhf CACHE STRING "Selected arm architecture" FORCE) +endif() +set(ARM_ARCH + armhf + CACHE STRING "Selected arm architecture" FORCE) diff --git a/cmake/gpl.txt b/cmake/gpl.txt index cd5c7e9b..14c186eb 100644 --- a/cmake/gpl.txt +++ b/cmake/gpl.txt @@ -410,4 +410,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/plugin.xml.in b/plugin.xml.in index 08336556..3f05d291 100644 --- a/plugin.xml.in +++ b/plugin.xml.in @@ -16,7 +16,7 @@ @pkg_target_arch@ @plugin_target_version@ - @ARCH@ + @target_arch@ @pkg_tarball_url@ - @checksum@ + @FILE_CHECKSUM@