From 2291275c84d7714d0d582830d28b8a6717012caf Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 21 Sep 2024 21:07:51 +0200 Subject: [PATCH] refs #12066 - added CMake option `BUILD_ONLINE_HELP` to conditionally add `online-help.qhc` target to CMake --- .github/workflows/CI-windows.yml | 61 ++++++++++++++++++++++++++++++-- cmake/findDependencies.cmake | 13 +++++++ cmake/options.cmake | 1 + cmake/printInfo.cmake | 1 + gui/CMakeLists.txt | 6 ++++ 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index 6128129c566e..b7a7c854ce98 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -68,8 +68,65 @@ jobs: run: | # TODO: enable rules? # specify Release build so matchcompiler is used - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On || exit /b !errorlevel! - cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel! + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel! + cmake --build build --target cppcheck-gui || exit /b !errorlevel! + + # TODO: deploy with CMake/Qt6 + + build: + strategy: + matrix: + os: [windows-2019, windows-2022] + config: [debug, release] + fail-fast: false + + runs-on: ${{ matrix.os }} + + env: + # see https://www.pcre.org/original/changelog.txt + PCRE_VERSION: 8.45 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + if: matrix.config == 'release' + uses: actions/setup-python@v5 + with: + python-version: '3.12' + check-latest: true + + - name: Set up Visual Studio environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - name: Cache PCRE + id: cache-pcre + uses: actions/cache@v4 + with: + path: | + externals\pcre.h + externals\pcre.lib + externals\pcre64.lib + key: pcre-${{ env.PCRE_VERSION }}-x64-bin-win + + - name: Download PCRE + if: steps.cache-pcre.outputs.cache-hit != 'true' + run: | + curl -fsSL https://github.com/pfultz2/pcre/archive/refs/tags/%PCRE_VERSION%.zip -o pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! + + - name: Install PCRE + if: steps.cache-pcre.outputs.cache-hit != 'true' + run: | + 7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! + cd pcre-%PCRE_VERSION% || exit /b !errorlevel! + cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTS=Off -DPCRE_BUILD_PCREGREP=Off || exit /b !errorlevel! + nmake || exit /b !errorlevel! + copy pcre.h ..\externals || exit /b !errorlevel! + copy pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel! + env: + CL: /MP - name: Deploy GUI if: startsWith(matrix.qt_ver, '6') diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index bdfc171d7e90..98421a02ee4e 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -28,6 +28,19 @@ if(BUILD_GUI) find_package(Qt5 COMPONENTS ${qt_components} REQUIRED) set(QT_VERSION "${Qt5Core_VERSION_STRING}") endif() + + if(BUILD_ONLINE_HELP) + find_program(QHELPGENERATOR qhelpgenerator) + if(NOT QHELPGENERATOR) + # TODO: how to properly get the Qt binary folder? + # piggy-back off Qt::qmake for now as it should be in the same folder as the binary we are looking for + get_target_property(_qmake_executable Qt::qmake IMPORTED_LOCATION) + get_filename_component(_qt_bin_dir ${_qmake_executable} DIRECTORY) + message(STATUS "qhelpgenerator not found in PATH - trying ${_qt_bin_dir}") + # cannot be mandatory since qhelpgenerator is missing from the official qttools Linux package - https://bugreports.qt.io/browse/QTBUG-116168 + find_program(QHELPGENERATOR qhelpgenerator HINTS ${_qt_bin_dir} REQUIRED) + endif() + endif() endif() if(HAVE_RULES) diff --git a/cmake/options.cmake b/cmake/options.cmake index 90c753358b04..eedc649f9bc3 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -57,6 +57,7 @@ option(BUILD_GUI "Build the qt application" option(WITH_QCHART "Enable QtCharts usage in the GUI" OFF) option(USE_QT6 "Prefer Qt6 when available" OFF) option(REGISTER_GUI_TESTS "Register GUI tests in CTest" ON) +option(BUILD_ONLINE_HELP "Build online help" OFF) option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF) option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON) diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index bb633650b7d1..976816450353 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -73,6 +73,7 @@ if(BUILD_GUI) message(STATUS "Qt5Core_LIBRARIES = ${Qt5Core_LIBRARIES}") message(STATUS "Qt5Core_INCLUDE_DIRS = ${Qt5Core_INCLUDE_DIRS}") endif() + message(STATUS "QHELPGENERATOR = ${QHELPGENERATOR}") endif() message(STATUS) message(STATUS "HAVE_RULES = ${HAVE_RULES}") diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 31fe62eaf64c..2f86d5683311 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -71,6 +71,12 @@ CheckOptions: target_compile_options_safe(cppcheck-gui -Wno-redundant-parens) endif() + if (QHELPGENERATOR) + # TODO: generate in CMAKE_BINARY_DIR folder + add_custom_target(online-help.qhc ${QHELPGENERATOR} ${CMAKE_CURRENT_SOURCE_DIR}/help/online-help.qhcp -o ${CMAKE_CURRENT_SOURCE_DIR}/help/online-help.qhc) + add_dependencies(cppcheck-gui online-help.qhc) + endif() + install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications) install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)