diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index eb3193f6..d660c3b4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,5 +13,8 @@ "github.vscode-github-actions" ] } + }, + "remoteEnv": { + "CPM_SOURCE_CACHE": "/root/cache/.cpm" } } diff --git a/.github/actions/build-test/action.yml b/.github/actions/build-test/action.yml new file mode 100644 index 00000000..d67b67ab --- /dev/null +++ b/.github/actions/build-test/action.yml @@ -0,0 +1,55 @@ +--- +name: Build and Test +description: Builds and tests the project using CMake + +inputs: + cpm-source-cache: + description: Path to the CPM source cache directory + required: true + use-ccache: + description: Use ccache to speed up builds + required: true + ccache-key: + description: Key for ccache cache + required: false + configure-preset: + description: CMake configure preset to use + required: true + build-preset: + description: CMake build preset to use + required: true + test-preset: + description: CMake test preset to use + required: true + +runs: + using: composite + steps: + - name: Restore CPM packages cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + id: cache-cpm + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} + + - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + if: ${{ inputs.use-ccache == 'true' }} + with: + key: ${{ inputs.ccache-key }} + max-size: 2G + save: ${{ !startsWith(github.ref, 'refs/tags/') }} + + - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + with: + configurePreset: "${{ inputs.configure-preset }}" + buildPreset: "${{ inputs.build-preset }}" + testPreset: "${{ inputs.test-preset }}" + env: + CPM_SOURCE_CACHE: ${{ inputs.cpm-source-cache }} + + - name: Save CPM packages cache + if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.cache-cpm.outputs.cache-hit != 'true' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 00000000..b99c9a55 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,52 @@ +--- +name: Build +description: Builds the project using CMake + +inputs: + cpm-source-cache: + description: Path to the CPM source cache directory + required: true + use-ccache: + description: Use ccache to speed up builds + required: true + ccache-key: + description: Key for ccache cache + required: false + configure-preset: + description: CMake configure preset to use + required: true + build-preset: + description: CMake build preset to use + required: true + +runs: + using: composite + steps: + - name: Restore CPM packages cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + id: cache-cpm + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} + + - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + if: ${{ inputs.use-ccache == 'true' }} + with: + key: ${{ inputs.ccache-key }} + max-size: 2G + save: ${{ !startsWith(github.ref, 'refs/tags/') }} + env: + CPM_SOURCE_CACHE: ${{ inputs.cpm-source-cache }} + + - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + with: + configurePreset: "${{ inputs.configure-preset }}" + buildPreset: "${{ inputs.build-preset }}" + + + - name: Save CPM packages cache + if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.cache-cpm.outputs.cache-hit != 'true' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} diff --git a/.github/actions/workflow/action.yml b/.github/actions/workflow/action.yml new file mode 100644 index 00000000..e0b486b2 --- /dev/null +++ b/.github/actions/workflow/action.yml @@ -0,0 +1,47 @@ +--- +name: Workflow Action +description: Uses a workflow preset for CMake + +inputs: + cpm-source-cache: + description: Path to the CPM source cache directory + required: true + use-ccache: + description: Use ccache to speed up builds + required: true + ccache-key: + description: Key for ccache cache + required: false + workflow-preset: + description: CMake workflow preset to use + required: true + +runs: + using: composite + steps: + - name: Restore CPM packages cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + id: cache-cpm + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} + + - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 + if: ${{ inputs.use-ccache == 'true' }} + with: + key: ${{ inputs.ccache-key }} + max-size: 2G + save: ${{ !startsWith(github.ref, 'refs/tags/') }} + + - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + with: + workflowPreset: "${{ inputs.workflow-preset }}" + env: + CPM_SOURCE_CACHE: ${{ inputs.cpm-source-cache }} + + - name: Save CPM packages cache + if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.cache-cpm.outputs.cache-hit != 'true' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ inputs.cpm-source-cache }} + key: cpm-${{ hashFiles('cmake/dependencies.cpm.cmake', 'cmake/package-lock.cmake') }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f1a12ef..275d2f82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ concurrency: env: GTEST_COLOR: 1 + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm jobs: build-in-devcontainer: @@ -33,27 +34,31 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + - if: ${{ matrix.target == 'Windows' }} uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 id: cache-winsdk with: path: /winsdk key: cache-winsdk-10.0.26100-14.43.17.13 + - if: ${{ matrix.target == 'Windows' && steps.cache-winsdk.outputs.cache-hit != 'true' }} run: ./get-winsdk.sh + - if: ${{ matrix.target == 'Windows' && steps.cache-winsdk.outputs.cache-hit != 'true' && github.event_name != 'pull_request' }} uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: /winsdk key: cache-winsdk-10.0.26100-14.43.17.13 - - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 - with: - key: ${{ github.job }}-${{ matrix.target }} - max-size: 2G - - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + + - name: Build + uses: ./.github/actions/build with: - configurePreset: "${{ matrix.target}}" - buildPreset: "${{ matrix.target}}-Release" + cpm-source-cache: ${{ env.CPM_SOURCE_CACHE }} + use-ccache: true + ccache-key: ${{ github.job }}-${{ matrix.target }} + configure-preset: "${{ matrix.target}}" + build-preset: "${{ matrix.target}}-Release" test-linux: name: Acceptance Test on Linux @@ -68,16 +73,19 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 - with: - key: ${{ github.job }} - max-size: 2G - - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + + - name: Build + uses: ./.github/actions/build with: - configurePreset: "Host" - buildPreset: "Host-Debug" + cpm-source-cache: ${{ env.CPM_SOURCE_CACHE }} + use-ccache: true + ccache-key: ${{ github.job }} + configure-preset: "Host" + build-preset: "Host-Debug" + - run: | bats --formatter junit cucumber_cpp/acceptance_test/test.bats | tee test-report.xml + - uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0 if: always() with: @@ -97,13 +105,15 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 - with: - key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.type }}${{ matrix.preset_suffix }} - max-size: 2G - - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + + - name: Build and test + uses: ./.github/actions/workflow with: - workflowPreset: "${{ matrix.os }}-Debug-${{ matrix.type }}${{ matrix.preset_suffix }}" + cpm-source-cache: ${{ env.CPM_SOURCE_CACHE }} + use-ccache: ${{ !startsWith(matrix.os, 'windows') }} + ccache-key: ccache-${{ github.job }}-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.type }}${{ matrix.preset_suffix }} + workflow-preset: "${{ matrix.os }}-Debug-${{ matrix.type }}${{ matrix.preset_suffix }}" + - name: Upload test logs if: ${{ failure() }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 787ec51d..fcd3b27d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -14,6 +14,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true +env: + GTEST_COLOR: 1 + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cpm + jobs: sonar: name: SonarCloud @@ -27,17 +31,15 @@ jobs: fetch-depth: 0 # Disable shallow clone to enable blame information persist-credentials: false - - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 - with: - key: ${{ github.job }} - max-size: 2G - - - name: Build for coverage - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + - name: Build + uses: ./.github/actions/build-test with: - configurePreset: "Coverage" - buildPreset: "Coverage" - testPreset: "Coverage" + cpm-source-cache: ${{ env.CPM_SOURCE_CACHE }} + use-ccache: true + ccache-key: ${{ github.job }} + configure-preset: "Coverage" + build-preset: "Coverage" + test-preset: "Coverage" env: GTEST_OUTPUT: "xml:${{ github.workspace }}/testresults/" @@ -66,21 +68,24 @@ jobs: codeql: name: CodeQL runs-on: ubuntu-latest - container: ghcr.io/philips-software/amp-devcontainer-cpp:8.0.1@sha256:489772f6e442f93804c0ccdb8879d84fbb1a70a203e8a2885ec97b39858bddee permissions: security-events: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23 - with: - key: ${{ github.job }} + - uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 with: languages: cpp - - uses: lukka/run-cmake@5d55ea7949e25f69f0ecb516d8d572297e03a956 # v10.9 + + - name: Build + uses: ./.github/actions/build with: - configurePreset: "Host" - buildPreset: "Host-Debug" + cpm-source-cache: ${{ env.CPM_SOURCE_CACHE }} + use-ccache: true + ccache-key: ${{ github.job }} + configure-preset: "Host" + build-preset: "Host-Debug" + - uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 61d7e4b2..cbd60866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.24) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") project(cucumber-cpp-runner LANGUAGES C CXX VERSION 4.1.0) # x-release-please-version -include(ccr_test_helpers) +include(cmake/ccr_test_helpers.cmake) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(CCR_STANDALONE On) @@ -12,7 +12,6 @@ endif() if (CCR_STANDALONE) set(CCR_DEFAULTOPT On) set(CCR_EXCLUDE_FROM_ALL "") - set(CMAKE_COMPILE_WARNING_AS_ERROR On) else() set(CCR_DEFAULTOPT Off) set(CCR_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL") @@ -61,26 +60,8 @@ include(FetchContent) include(GNUInstallDirs) include(CTest) -if (CCR_FETCH_DEPS) - add_subdirectory(external) -else() - find_package(CLI11 REQUIRED) - find_package(nlohmann_json REQUIRED) - find_package(GTest REQUIRED) - find_package(pugixml REQUIRED) - find_package(cucumber_messages REQUIRED) - find_package(cucumber_gherkin REQUIRED) - find_package(fmt REQUIRED) - - if (CCR_BUILD_TESTS) - find_package(yaml-cpp REQUIRED) - endif() - - if (CCR_USE_RE2) - find_package(absl) - find_package(re2) - endif() -endif() +include(cmake/dependencies.cpm.cmake) +add_subdirectory(external) if (TARGET re2::re2) set(CCR_HAS_RE2 On) @@ -92,15 +73,19 @@ endif() # libraries (abseil, re2) are not compiled with sanitizer instrumentation. # Abseil's constexpr function-pointer comparisons are not compatible with GCC's # ASan/UBSan instrumentation, which causes build failures. -if (CCR_STANDALONE AND NOT CCR_ENABLE_COVERAGE) +if (PROJECT_IS_TOP_LEVEL AND NOT CCR_ENABLE_COVERAGE) if (NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) add_compile_options(-fsanitize=address -fsanitize=undefined) add_link_options(-fsanitize=address -fsanitize=undefined) endif() endif() +if(PROJECT_IS_TOP_LEVEL) + set(CMAKE_COMPILE_WARNING_AS_ERROR On) +endif() + add_subdirectory(cucumber_cpp) -if (CCR_STANDALONE) +if (PROJECT_IS_TOP_LEVEL) add_subdirectory(compatibility) endif() diff --git a/cmake/dependencies.cpm.cmake b/cmake/dependencies.cpm.cmake new file mode 100644 index 00000000..fc6369fa --- /dev/null +++ b/cmake/dependencies.cpm.cmake @@ -0,0 +1,186 @@ +macro(ccr_dependency PREFIX TAG DIGEST) + set(${PREFIX}_TAG "${TAG}") + set(${PREFIX}_DIGEST "${DIGEST}") + string(REGEX REPLACE "^v" "" ${PREFIX}_VERSION "${TAG}") +endmacro() + +# renovate: datasource=github-tags packageName=cpm-cmake/CPM.cmake versioning=semver +ccr_dependency(CPM_DOWNLOAD v0.43.1 456cb6754daaa010d57444d0c8ce6d95ecf006ab) +set(CPM_DOWNLOAD_SHA256 "1c40fc102ce9625d7de7eb14f541cab30cc3138dca627f0b0ec40293ce6c2934") +# renovate: datasource=github-tags packageName=nlohmann/json versioning=semver +ccr_dependency(NLOHMANN_JSON v3.12.0 55f93686c01528224f448c19128836e7df245f72) +# renovate: datasource=github-tags packageName=cucumber/messages versioning=semver +ccr_dependency(CUCUMBER_MESSAGES v34.2.0 073f951ce615149a1532185fbae013ad908a918e) +# renovate: datasource=github-tags packageName=cucumber/gherkin versioning=semver +ccr_dependency(CUCUMBER_GHERKIN v42.0.0 f2f7b51ae6a886aefc1f4a2059e4989b83aab8c8) +# renovate: datasource=github-tags packageName=google/googletest versioning=semver +ccr_dependency(GOOGLE_TEST v1.17.0 52eb8108c5bdec04579160ae17225d66034bd723) +# renovate: datasource=github-tags packageName=CLIUtils/CLI11 versioning=semver +ccr_dependency(CLI11 v2.6.2 37bb6edc5317e99af72ef48405e65d9ca5218861) +# renovate: datasource=github-tags packageName=fmtlib/fmt versioning=semver +ccr_dependency(LIBFMT v12.1.0 407c905e45ad75fc29bf0f9bb7c5c2fd3475976f) +# renovate: datasource=github-tags packageName=zeux/pugixml versioning=semver +ccr_dependency(PUGIXML v1.15 ee86beb30e4973f5feffe3ce63bfa4fbadf72f38) +# renovate: datasource=github-tags packageName=abseil/abseil-cpp +ccr_dependency(ABSEIL_CPP 20250814.2 0cf0a5c9d12cc3783363ab20f11613e69fd04c9a) +# renovate: datasource=github-tags packageName=google/re2 +ccr_dependency(RE2 2025-08-12 0f6c07eae69151e606acb3d9232750c3442dff23) +# renovate: datasource=github-tags packageName=jbeder/yaml-cpp versioning=semver +ccr_dependency(YAML_CPP v0.9.0 56e3bb550c91fd7005566f19c079cb7a503223cf) + +if(CCR_FETCH_DEPS) + if(NOT COMMAND CPMAddPackage) + # --------------------------------------------------------------------------- + # CPM – download on first configure if not already cached + # --------------------------------------------------------------------------- + set(CPM_USE_LOCAL_PACKAGES ON) + set(CPM_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + + if(NOT EXISTS "${CPM_DOWNLOAD_LOCATION}") + message(STATUS "Downloading CPM.cmake ${CPM_DOWNLOAD_VERSION}…") + file(DOWNLOAD + "https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_DOWNLOAD_TAG}/CPM.cmake" + "${CPM_DOWNLOAD_LOCATION}" + TLS_VERIFY ON + EXPECTED_HASH SHA256=${CPM_DOWNLOAD_SHA256} + STATUS CPM_DOWNLOAD_STATUS + ) + list(GET CPM_DOWNLOAD_STATUS 0 CPM_DOWNLOAD_STATUS_code) + if(NOT CPM_DOWNLOAD_STATUS_code EQUAL 0) + message(FATAL_ERROR "Failed to download CPM.cmake: ${CPM_DOWNLOAD_STATUS}") + endif() + endif() + + include("${CPM_DOWNLOAD_LOCATION}") + endif() + + CPMUsePackageLock("${CMAKE_CURRENT_LIST_DIR}/package-lock.cmake") + + # --------------------------------------------------------------------------- + # + # Dependencies + # + # --------------------------------------------------------------------------- + + # --------------------------------------------------------------------------- + # nlohmann_json + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:nlohmann/json@${NLOHMANN_JSON_VERSION}#${NLOHMANN_JSON_DIGEST}" + NAME nlohmann_json + OPTIONS + "JSON_BuildTests Off" + "JSON_Install ON" + ) + + # --------------------------------------------------------------------------- + # cucumber_messages + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:cucumber/messages@${CUCUMBER_MESSAGES_VERSION}#${CUCUMBER_MESSAGES_DIGEST}" + NAME cucumber_messages + SOURCE_SUBDIR cpp + ) + + # --------------------------------------------------------------------------- + # cucumber_gherkin + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:cucumber/gherkin@${CUCUMBER_GHERKIN_VERSION}#${CUCUMBER_GHERKIN_DIGEST}" + NAME cucumber_gherkin + SOURCE_SUBDIR cpp + ) + + # --------------------------------------------------------------------------- + # GoogleTest + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:google/googletest@${GOOGLE_TEST_VERSION}#${GOOGLE_TEST_DIGEST}" + NAME googletest + OPTIONS + "INSTALL_GTEST OFF" + "gtest_force_shared_crt ON" + ) + + if (TARGET gtest) + set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES + FOLDER External/GoogleTest + ) + endif() + + # --------------------------------------------------------------------------- + # cli11 + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:CLIUtils/CLI11@${CLI11_VERSION}#${CLI11_DIGEST}" + NAME cli11 + ) + + # --------------------------------------------------------------------------- + # libfmt + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:fmtlib/fmt@${LIBFMT_VERSION}#${LIBFMT_DIGEST}" + NAME libfmt + ) + + # --------------------------------------------------------------------------- + # pugixml + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:zeux/pugixml@${PUGIXML_VERSION}#${PUGIXML_DIGEST}" + NAME pugixml + ) + + if (CCR_USE_RE2) + # --------------------------------------------------------------------------- + # abseil-cpp + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:abseil/abseil-cpp@${ABSEIL_CPP_VERSION}#${ABSEIL_CPP_DIGEST}" + NAME abseil-cpp + OPTIONS + "ABSL_PROPAGATE_CXX_STD ON" + "ABSL_ENABLE_INSTALL ON" + ) + + # --------------------------------------------------------------------------- + # re2 + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:google/re2#${RE2_DIGEST}" + NAME re2 + OPTIONS + "RE2_BUILD_TESTING OFF" + ) + endif() + + if (CCR_BUILD_TESTS) + # --------------------------------------------------------------------------- + # yaml-cpp + # --------------------------------------------------------------------------- + CPMAddPackage( + URI "gh:jbeder/yaml-cpp@${YAML_CPP_VERSION}#${YAML_CPP_DIGEST}" + NAME yaml-cpp + OPTIONS + "YAML_ENABLE_PIC OFF" + ) + endif() +else() + find_package(CLI11 ${CLI11_VERSION} REQUIRED) + find_package(nlohmann_json ${NLOHMANN_JSON_VERSION} REQUIRED) + find_package(cucumber_messages ${CUCUMBER_MESSAGES_VERSION} REQUIRED) + find_package(cucumber_gherkin ${CUCUMBER_GHERKIN_VERSION} REQUIRED) + find_package(GTest REQUIRED) + find_package(pugixml ${PUGIXML_VERSION} REQUIRED) + find_package(fmt ${LIBFMT_VERSION} REQUIRED) + + if (CCR_USE_RE2) + find_package(absl ${ABSEIL_CPP_VERSION}) + find_package(re2) + endif() + + if (CCR_BUILD_TESTS) + find_package(yaml-cpp ${YAML_CPP_VERSION} REQUIRED) + endif() +endif() diff --git a/cmake/package-lock.cmake b/cmake/package-lock.cmake new file mode 100644 index 00000000..742ce9cd --- /dev/null +++ b/cmake/package-lock.cmake @@ -0,0 +1,107 @@ +# CPM Package Lock +# This file should be committed to version control + +# nlohmann_json +CPMDeclarePackage(nlohmann_json + NAME nlohmann_json + VERSION 3.12.0 + GIT_TAG 55f93686c01528224f448c19128836e7df245f72 + GITHUB_REPOSITORY nlohmann/json + SYSTEM YES + EXCLUDE_FROM_ALL YES + OPTIONS + "JSON_BuildTests Off" + "JSON_Install ON" +) +# cucumber_messages +CPMDeclarePackage(cucumber_messages + NAME cucumber_messages + VERSION 34.2.0 + GIT_TAG 073f951ce615149a1532185fbae013ad908a918e + GITHUB_REPOSITORY cucumber/messages + SYSTEM YES + EXCLUDE_FROM_ALL YES + SOURCE_SUBDIR cpp +) +# cucumber_gherkin +CPMDeclarePackage(cucumber_gherkin + NAME cucumber_gherkin + VERSION 42.0.0 + GIT_TAG f2f7b51ae6a886aefc1f4a2059e4989b83aab8c8 + GITHUB_REPOSITORY cucumber/gherkin + SYSTEM YES + EXCLUDE_FROM_ALL YES + SOURCE_SUBDIR cpp +) +# googletest +CPMDeclarePackage(googletest + NAME googletest + VERSION 1.17.0 + GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 + GITHUB_REPOSITORY google/googletest + SYSTEM YES + EXCLUDE_FROM_ALL YES + OPTIONS + "INSTALL_GTEST OFF" + "gtest_force_shared_crt ON" +) +# cli11 +CPMDeclarePackage(cli11 + NAME cli11 + VERSION 2.6.2 + GIT_TAG 37bb6edc5317e99af72ef48405e65d9ca5218861 + GITHUB_REPOSITORY CLIUtils/CLI11 + SYSTEM YES + EXCLUDE_FROM_ALL YES +) +# libfmt +CPMDeclarePackage(libfmt + NAME libfmt + VERSION 12.1.0 + GIT_TAG 407c905e45ad75fc29bf0f9bb7c5c2fd3475976f + GITHUB_REPOSITORY fmtlib/fmt + SYSTEM YES + EXCLUDE_FROM_ALL YES +) +# pugixml +CPMDeclarePackage(pugixml + NAME pugixml + VERSION 1.15 + GIT_TAG ee86beb30e4973f5feffe3ce63bfa4fbadf72f38 + GITHUB_REPOSITORY zeux/pugixml + SYSTEM YES + EXCLUDE_FROM_ALL YES +) +# abseil-cpp +CPMDeclarePackage(abseil-cpp + NAME abseil-cpp + VERSION 20250814.2 + GIT_TAG 0cf0a5c9d12cc3783363ab20f11613e69fd04c9a + GITHUB_REPOSITORY abseil/abseil-cpp + SYSTEM YES + EXCLUDE_FROM_ALL YES + OPTIONS + "ABSL_PROPAGATE_CXX_STD ON" + "ABSL_ENABLE_INSTALL ON" +) +# re2 (unversioned) +# CPMDeclarePackage(re2 +# NAME re2 +# GIT_TAG 0f6c07eae69151e606acb3d9232750c3442dff23 +# GITHUB_REPOSITORY google/re2 +# SYSTEM YES +# EXCLUDE_FROM_ALL YES +# OPTIONS +# "RE2_BUILD_TESTING OFF" +#) +# yaml-cpp +CPMDeclarePackage(yaml-cpp + NAME yaml-cpp + VERSION 0.9.0 + GIT_TAG 56e3bb550c91fd7005566f19c079cb7a503223cf + GITHUB_REPOSITORY jbeder/yaml-cpp + SYSTEM YES + EXCLUDE_FROM_ALL YES + OPTIONS + "YAML_ENABLE_PIC OFF" +) diff --git a/compatibility/BaseCompatibility.cpp b/compatibility/BaseCompatibility.cpp index aae24f9c..fb1da6e8 100644 --- a/compatibility/BaseCompatibility.cpp +++ b/compatibility/BaseCompatibility.cpp @@ -4,7 +4,7 @@ #include "cucumber_cpp/library/api/Formatters.hpp" #include "cucumber_cpp/library/api/RunCucumber.hpp" #include "cucumber_cpp/library/cucumber_expression/ParameterRegistry.hpp" -#include "cucumber_cpp/library/support/SupportCodeLibrary.hpp" +#include "cucumber_cpp/library/support/DefinitionRegistration.hpp" #include "cucumber_cpp/library/support/Types.hpp" #include "cucumber_cpp/library/tag_expression/Parser.hpp" #include "cucumber_cpp/library/util/Broadcaster.hpp" @@ -70,7 +70,11 @@ namespace compatibility uri = std::regex_replace(uri, std::regex(R"(samples\/[^\/]+)"), devkit.folder); uri = std::regex_replace(uri, std::regex(R"(\.ts$)"), ".cpp"); - json[key] = std::filesystem::canonical(uri).string(); + std::filesystem::path path{ uri }; + if (path.is_relative()) + path = std::filesystem::path{ CCR_BINARY_DIR } / path; + + json[key] = std::filesystem::canonical(path).string(); ++jsonIter; } diff --git a/compatibility/CMakeLists.txt b/compatibility/CMakeLists.txt index f65ce043..b9372459 100644 --- a/compatibility/CMakeLists.txt +++ b/compatibility/CMakeLists.txt @@ -13,6 +13,11 @@ target_include_directories(compatibility.base PUBLIC $ ) +file(TO_CMAKE_PATH "${CMAKE_BINARY_DIR}" CCR_BINARY_DIR_CMAKE) +target_compile_definitions(compatibility.base PRIVATE + CCR_BINARY_DIR="${CCR_BINARY_DIR_CMAKE}" +) + function(add_compatibility_kit name) set(libname compatibility.${name}.test) add_executable(${libname}) @@ -34,7 +39,6 @@ function(add_compatibility_kit name) TestCompatibility.cpp ) - if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/${name}/${name}.cpp) target_sources(${libname} PRIVATE ${name}/${name}.cpp diff --git a/compatibility/attachments/attachments.cpp b/compatibility/attachments/attachments.cpp index 08952d2b..eb23409d 100644 --- a/compatibility/attachments/attachments.cpp +++ b/compatibility/attachments/attachments.cpp @@ -10,7 +10,7 @@ namespace { - const std::filesystem::path currentCompileDir = std::filesystem::path{ std::source_location::current().file_name() }.parent_path(); + const std::filesystem::path compatibilityPath = std::filesystem::path{ KIT_FOLDER }; } WHEN(R"(the string {string} is attached as {string})", (const std::string& text, const std::string& mediaType)) @@ -43,7 +43,7 @@ WHEN(R"(an array with {int} bytes is attached as {string})", (std::int32_t size, WHEN(R"(a PDF document is attached and renamed)") { - std::ifstream pdfFile{ currentCompileDir / "document.pdf", std::ios::binary }; + std::ifstream pdfFile{ compatibilityPath / "document.pdf", std::ios::binary }; Attach(pdfFile, cucumber_cpp::AttachOptions{ .mediaType = "application/pdf", .fileName = "renamed.pdf" }); } diff --git a/compatibility/examples-tables-attachment/examples-tables-attachment.cpp b/compatibility/examples-tables-attachment/examples-tables-attachment.cpp index 6dd3df37..155f9301 100644 --- a/compatibility/examples-tables-attachment/examples-tables-attachment.cpp +++ b/compatibility/examples-tables-attachment/examples-tables-attachment.cpp @@ -8,17 +8,17 @@ namespace { - const std::filesystem::path currentCompileDir = std::filesystem::path{ std::source_location::current().file_name() }.parent_path(); + const std::filesystem::path compatibilityPath = std::filesystem::path{ KIT_FOLDER }; } WHEN(R"(a JPEG image is attached)") { - std::ifstream jpegFile{ currentCompileDir / "cucumber.jpeg", std::ios::binary }; + std::ifstream jpegFile{ compatibilityPath / "cucumber.jpeg", std::ios::binary }; Attach(jpegFile, "image/jpeg"); } WHEN(R"(a PNG image is attached)") { - std::ifstream pngFile{ currentCompileDir / "cucumber.png", std::ios::binary }; + std::ifstream pngFile{ compatibilityPath / "cucumber.png", std::ios::binary }; Attach(pngFile, "image/png"); } diff --git a/compatibility/hooks-attachment/hooks-attachment.cpp b/compatibility/hooks-attachment/hooks-attachment.cpp index ee05a003..6731236a 100644 --- a/compatibility/hooks-attachment/hooks-attachment.cpp +++ b/compatibility/hooks-attachment/hooks-attachment.cpp @@ -7,12 +7,12 @@ namespace { - const std::filesystem::path currentCompileDir = std::filesystem::path{ std::source_location::current().file_name() }.parent_path(); + const std::filesystem::path compatibilityPath = std::filesystem::path{ KIT_FOLDER }; } HOOK_BEFORE_SCENARIO() { - std::ifstream svgFile{ currentCompileDir / "cucumber.svg", std::ios::binary }; + std::ifstream svgFile{ compatibilityPath / "cucumber.svg", std::ios::binary }; Attach(svgFile, "image/svg+xml"); } @@ -23,6 +23,6 @@ WHEN(R"(a step passes)") HOOK_AFTER_SCENARIO() { - std::ifstream svgFile{ currentCompileDir / "cucumber.svg", std::ios::binary }; + std::ifstream svgFile{ compatibilityPath / "cucumber.svg", std::ios::binary }; Attach(svgFile, "image/svg+xml"); } diff --git a/cucumber_cpp/library/support/StepRegistry.cpp b/cucumber_cpp/library/support/StepRegistry.cpp index 78a6410e..bbfcd9e5 100644 --- a/cucumber_cpp/library/support/StepRegistry.cpp +++ b/cucumber_cpp/library/support/StepRegistry.cpp @@ -1,6 +1,5 @@ #include "cucumber_cpp/library/support/StepRegistry.hpp" #include "cucumber/gherkin/id_generator.hpp" -#include "cucumber/messages/step_definition_pattern_type.hpp" #include "cucumber_cpp/library/cucumber_expression/Argument.hpp" #include "cucumber_cpp/library/cucumber_expression/Errors.hpp" #include "cucumber_cpp/library/cucumber_expression/Expression.hpp" @@ -17,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/cucumber_cpp/library/support/StepRegistry.hpp b/cucumber_cpp/library/support/StepRegistry.hpp index 9b07c30d..edfb4b94 100644 --- a/cucumber_cpp/library/support/StepRegistry.hpp +++ b/cucumber_cpp/library/support/StepRegistry.hpp @@ -136,7 +136,8 @@ namespace cucumber_cpp::library::support , regex{ std::move(regex) } , factory{ factory } , sourceLocation{ sourceLocation } - {} + { + } StepType type{}; std::string regex; diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 6de30b50..9d8247d8 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,14 +1,4 @@ set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "") set(CMAKE_COMPILE_WARNING_AS_ERROR Off) -add_subdirectory(nlohmann) # before cucumber - -add_subdirectory(cliutils) -add_subdirectory(cucumber) -add_subdirectory(fmtlib) -add_subdirectory(google) -if (CCR_BUILD_TESTS) - add_subdirectory(jbeder) -endif() add_subdirectory(tobiaslocker) -add_subdirectory(zeux) diff --git a/external/cliutils/CMakeLists.txt b/external/cliutils/CMakeLists.txt deleted file mode 100644 index 148e407a..00000000 --- a/external/cliutils/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(cli11) diff --git a/external/cliutils/cli11/CMakeLists.txt b/external/cliutils/cli11/CMakeLists.txt deleted file mode 100644 index 3f54011e..00000000 --- a/external/cliutils/cli11/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -FetchContent_Declare( - cli11 - GIT_REPOSITORY https://github.com/CLIUtils/CLI11 - GIT_TAG 37bb6edc5317e99af72ef48405e65d9ca5218861 # v2.6.2 -) - -set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL On) - -# set(ARGS_BUILD_EXAMPLE Off CACHE INTERNAL "") -# set(ARGS_BUILD_UNITTESTS Off CACHE INTERNAL "") - -FetchContent_MakeAvailable(cli11) - -# set_target_properties(cli11 PROPERTIES FOLDER External/cli11) diff --git a/external/cucumber/CMakeLists.txt b/external/cucumber/CMakeLists.txt deleted file mode 100644 index 6c00ddcd..00000000 --- a/external/cucumber/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(messages) # before gherkin -add_subdirectory(gherkin) diff --git a/external/cucumber/gherkin/CMakeLists.txt b/external/cucumber/gherkin/CMakeLists.txt deleted file mode 100644 index 0068c05d..00000000 --- a/external/cucumber/gherkin/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -FetchContent_Declare( - cucumber_gherkin - GIT_REPOSITORY https://github.com/cucumber/gherkin.git - GIT_TAG f2f7b51ae6a886aefc1f4a2059e4989b83aab8c8 # v42.0.0 -) - -FetchContent_MakeAvailable(cucumber_gherkin) - -add_subdirectory(${cucumber_gherkin_SOURCE_DIR}/cpp ${cucumber_gherkin_BINARY_DIR}/cpp) - -# The usage of designated initializers requires c++20 in MSVC -set_target_properties(cucumber_gherkin_lib PROPERTIES CXX_STANDARD 20) -set_target_properties(cucumber_gherkin_bin PROPERTIES CXX_STANDARD 20) -set_target_properties(cucumber_gherkin_generate_tokens_bin PROPERTIES CXX_STANDARD 20) - -# Mark cucumber_gherkin_lib include directories as SYSTEM so that deprecation -# warnings in third-party headers (e.g. std::wstring_convert in utils.hpp) -# are not raised as errors in consuming targets. -get_target_property(_gherkin_includes cucumber_gherkin_lib INTERFACE_INCLUDE_DIRECTORIES) -set_target_properties(cucumber_gherkin_lib PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_gherkin_includes}") diff --git a/external/cucumber/messages/CMakeLists.txt b/external/cucumber/messages/CMakeLists.txt deleted file mode 100644 index 613de8ed..00000000 --- a/external/cucumber/messages/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -FetchContent_Declare( - cucumber_messages - GIT_REPOSITORY https://github.com/cucumber/messages.git - GIT_TAG 073f951ce615149a1532185fbae013ad908a918e # v34.2.0 - OVERRIDE_FIND_PACKAGE -) - -FetchContent_MakeAvailable(cucumber_messages) - -add_subdirectory(${cucumber_messages_SOURCE_DIR}/cpp ${cucumber_messages_BINARY_DIR}/cpp) - -target_compile_options(cucumber_messages_lib PUBLIC - # cucumber_gherkin-src/cpp/include/gherkin/cucumber/gherkin/utils.hpp:34:31: error: 'codecvt_utf8' is deprecated - $<$:-Wno-deprecated-declarations> -) diff --git a/external/fmtlib/CMakeLists.txt b/external/fmtlib/CMakeLists.txt deleted file mode 100644 index 468fe7de..00000000 --- a/external/fmtlib/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(fmt) diff --git a/external/fmtlib/fmt/CMakeLists.txt b/external/fmtlib/fmt/CMakeLists.txt deleted file mode 100644 index b5ad181c..00000000 --- a/external/fmtlib/fmt/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -FetchContent_Declare( - libfmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG 407c905e45ad75fc29bf0f9bb7c5c2fd3475976f # 12.1.0 -) - -FetchContent_MakeAvailable(libfmt) diff --git a/external/google/CMakeLists.txt b/external/google/CMakeLists.txt deleted file mode 100644 index b307909f..00000000 --- a/external/google/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -if (CCR_USE_RE2) - add_subdirectory(abseil) # before re2 - add_subdirectory(re2) -endif() -add_subdirectory(googletest) diff --git a/external/google/abseil/CMakeLists.txt b/external/google/abseil/CMakeLists.txt deleted file mode 100644 index 1713d7d4..00000000 --- a/external/google/abseil/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -FetchContent_Declare( - absl - GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git - GIT_TAG 0cf0a5c9d12cc3783363ab20f11613e69fd04c9a # 20250814.2 - OVERRIDE_FIND_PACKAGE -) - -set(ABSL_PROPAGATE_CXX_STD On CACHE BOOL "" FORCE) -set(ABSL_ENABLE_INSTALL On CACHE BOOL "" FORCE) - -FetchContent_MakeAvailable(absl) diff --git a/external/google/googletest/CMakeLists.txt b/external/google/googletest/CMakeLists.txt deleted file mode 100644 index 0934eba7..00000000 --- a/external/google/googletest/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -if(NOT TARGET gtest) - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 # v1.17.0 - ) - - set(gtest_force_shared_crt On CACHE BOOL "" FORCE) # For Windows: Prevent overriding the parent project's compiler/linker settings - set(INSTALL_GTEST Off CACHE BOOL "" FORCE) - - FetchContent_MakeAvailable(googletest) - - set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES FOLDER External/GoogleTest) - - # clang-22 promoted -Wcharacter-conversion to an on-by-default warning - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 22.0.0) - target_compile_options(gtest INTERFACE -Wno-character-conversion) - target_compile_options(gtest_main INTERFACE -Wno-character-conversion) - target_compile_options(gmock INTERFACE -Wno-character-conversion) - target_compile_options(gmock_main INTERFACE -Wno-character-conversion) - endif() - endif() - mark_as_advanced(BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS gmock_build_tests gtest_build_samples test_build_tests gtest_disable_pthreads gtest_force_shared_crt gtest_hide_internal_symbols) -endif() diff --git a/external/google/re2/CMakeLists.txt b/external/google/re2/CMakeLists.txt deleted file mode 100644 index 0cd9b7e0..00000000 --- a/external/google/re2/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -FetchContent_Declare( - re2 - GIT_REPOSITORY https://github.com/google/re2.git - GIT_TAG 0f6c07eae69151e606acb3d9232750c3442dff23 # 2025-08-12 - OVERRIDE_FIND_PACKAGE -) - -set(RE2_BUILD_TESTING Off CACHE BOOL "" FORCE) - -FetchContent_MakeAvailable(re2) diff --git a/external/jbeder/CMakeLists.txt b/external/jbeder/CMakeLists.txt deleted file mode 100644 index 74eaddec..00000000 --- a/external/jbeder/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(yaml-cpp) diff --git a/external/jbeder/yaml-cpp/CMakeLists.txt b/external/jbeder/yaml-cpp/CMakeLists.txt deleted file mode 100644 index fe193f26..00000000 --- a/external/jbeder/yaml-cpp/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -FetchContent_Declare( - yaml-cpp - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git - GIT_TAG 56e3bb550c91fd7005566f19c079cb7a503223cf # yaml-cpp-0.9.0 -) - -set(YAML_ENABLE_PIC OFF CACHE STRING "") - -FetchContent_MakeAvailable(yaml-cpp) diff --git a/external/nlohmann/CMakeLists.txt b/external/nlohmann/CMakeLists.txt deleted file mode 100644 index 7a340d53..00000000 --- a/external/nlohmann/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(json) diff --git a/external/nlohmann/json/CMakeLists.txt b/external/nlohmann/json/CMakeLists.txt deleted file mode 100644 index 9f4a28eb..00000000 --- a/external/nlohmann/json/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -FetchContent_Declare(nlohmann_json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG 55f93686c01528224f448c19128836e7df245f72 # v3.12.0 - OVERRIDE_FIND_PACKAGE -) - -# required for cucumber/messages and cucumber/gherkin -set(JSON_Install "On") - -FetchContent_MakeAvailable(nlohmann_json) diff --git a/external/zeux/CMakeLists.txt b/external/zeux/CMakeLists.txt deleted file mode 100644 index 7cc8a3d5..00000000 --- a/external/zeux/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(pugixml) diff --git a/external/zeux/pugixml/CMakeLists.txt b/external/zeux/pugixml/CMakeLists.txt deleted file mode 100644 index a6df3dc8..00000000 --- a/external/zeux/pugixml/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -FetchContent_Declare(pugixml - GIT_REPOSITORY https://github.com/zeux/pugixml.git - GIT_TAG ee86beb30e4973f5feffe3ce63bfa4fbadf72f38 # v1.15 -) - -FetchContent_MakeAvailable(pugixml)