diff --git a/.exemplar_version b/.exemplar_version index 5223332..af3c4f0 100644 --- a/.exemplar_version +++ b/.exemplar_version @@ -1 +1 @@ -b1e7015b1bd62ce5b20009cec7ee98ba5c783818 +a8a97fdec16bfd081aa1814402f13b6a20327046 diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index fe2e5ef..ae7cedd 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -13,10 +13,10 @@ on: jobs: beman-submodule-check: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.6.0 preset-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.6.0 with: matrix_config: > [ @@ -31,7 +31,7 @@ jobs: ] build-and-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.6.0 with: matrix_config: > { @@ -123,7 +123,12 @@ jobs: ] } + vcpkg-ci: + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-ci.yml@1.6.0 + with: + port_name: beman-transform-view + create-issue-when-fault: needs: [preset-test, build-and-test] if: failure() && github.event_name == 'schedule' - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.6.0 diff --git a/.github/workflows/pre-commit-check.yml b/.github/workflows/pre-commit-check.yml index 2004ccf..e5df5ee 100644 --- a/.github/workflows/pre-commit-check.yml +++ b/.github/workflows/pre-commit-check.yml @@ -10,4 +10,4 @@ on: jobs: pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.6.0 diff --git a/.github/workflows/pre-commit-update.yml b/.github/workflows/pre-commit-update.yml index 354aba6..445c891 100644 --- a/.github/workflows/pre-commit-update.yml +++ b/.github/workflows/pre-commit-update.yml @@ -9,7 +9,7 @@ on: jobs: auto-update-pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.6.0 secrets: APP_ID: ${{ secrets.AUTO_PR_BOT_APP_ID }} PRIVATE_KEY: ${{ secrets.AUTO_PR_BOT_PRIVATE_KEY }} diff --git a/.github/workflows/vcpkg-release.yml b/.github/workflows/vcpkg-release.yml new file mode 100644 index 0000000..872dc7f --- /dev/null +++ b/.github/workflows/vcpkg-release.yml @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +name: vcpkg registry release +on: + release: + types: [published] +jobs: + vcpkg-release: + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-release.yml@1.6.0 + with: + port_name: beman-transform-view + secrets: + VCPKG_REGISTRY_TOKEN: ${{ secrets.VCPKG_REGISTRY_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a790d5..cbf059b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,4 +45,4 @@ repos: hooks: - id: beman-tidy -exclude: 'cookiecutter/|infra/' +exclude: 'cookiecutter/|infra/|port/' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73cf7c3..aa6f345 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,30 @@ ctest --test-dir build ## Dependency Management +### vcpkg + +The best way to install the project's dependencies is to use the vcpkg workflow. + +To do so, make sure vcpkg is installed and `VCPKG_ROOT` is defined in your environment, +then specify +`-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"`. Vcpkg will handle +the project's dependencies, including GoogleTest. + +Example commands: + +``` +cmake \ + -B build \ + -S . \ + -DCMAKE_CXX_STANDARD=17 \ + -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" +cmake --build build +ctest --test-dir build +``` + +The file `./vcpkg.json` configures the list of dependencies that will be configured by +vcpkg. + ### FetchContent Instead of installing the project's dependencies via a package manager, you can optionally diff --git a/README.md b/README.md index 3d31b5c..07f92ec 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,17 @@ For details on building beman.transform_view without using a CMake preset, refer ### Installation +#### Vcpkg + +The preferred way to install transform_view is via vcpkg. To do so, after installing vcpkg +itself, you need to add support for the Beman project's [vcpkg +registry](https://github.com/bemanproject/vcpkg-registry) by configuring a +`vcpkg-configuration.json` file (which transform_view [provides](vcpkg-configuration.json)). + +Then, simply run `vcpkg install beman-transform-view`. + +#### Manual + To install beman.transform_view globally after building with the `gcc-release` preset, you can run: diff --git a/infra/.beman_submodule b/infra/.beman_submodule index 8463363..033dea5 100644 --- a/infra/.beman_submodule +++ b/infra/.beman_submodule @@ -1,3 +1,3 @@ [beman_submodule] remote=https://github.com/bemanproject/infra.git -commit_hash=dfdb103b5fc9cccd3424c377130e318466f1dd89 +commit_hash=3a49dffbffbfd1c405ce36091dfc68ad02dd6965 diff --git a/infra/cmake/use-fetch-content.cmake b/infra/cmake/use-fetch-content.cmake index f2428b5..a089130 100644 --- a/infra/cmake/use-fetch-content.cmake +++ b/infra/cmake/use-fetch-content.cmake @@ -157,7 +157,50 @@ function(BemanExemplar_provideDependency method package_name) GIT_TAG "${BemanExemplar_tag}" EXCLUDE_FROM_ALL ) - set(INSTALL_GTEST OFF) # Disable GoogleTest installation + + # Apply per-dependency cmake_args from the lockfile + string( + JSON BemanExemplar_cmakeArgs + ERROR_VARIABLE BemanExemplar_cmakeArgsError + GET "${BemanExemplar_depObj}" + "cmake_args" + ) + if(NOT BemanExemplar_cmakeArgsError) + string( + JSON BemanExemplar_numCmakeArgs + LENGTH "${BemanExemplar_cmakeArgs}" + ) + if(BemanExemplar_numCmakeArgs GREATER 0) + math( + EXPR + BemanExemplar_maxArgIndex + "${BemanExemplar_numCmakeArgs} - 1" + ) + foreach( + BemanExemplar_argIndex + RANGE "${BemanExemplar_maxArgIndex}" + ) + string( + JSON BemanExemplar_argKey + MEMBER "${BemanExemplar_cmakeArgs}" + "${BemanExemplar_argIndex}" + ) + string( + JSON BemanExemplar_argValue + GET "${BemanExemplar_cmakeArgs}" + "${BemanExemplar_argKey}" + ) + message( + DEBUG + "Setting ${BemanExemplar_argKey}=${BemanExemplar_argValue} for ${BemanExemplar_name}" + ) + set("${BemanExemplar_argKey}" + "${BemanExemplar_argValue}" + ) + endforeach() + endif() + endif() + FetchContent_MakeAvailable("${BemanExemplar_name}") # Catch2's CTest integration module isn't on CMAKE_MODULE_PATH @@ -179,6 +222,8 @@ function(BemanExemplar_provideDependency method package_name) endforeach() endfunction() +set(BEMAN_USE_FETCH_CONTENT_ENABLED ON) + cmake_language( SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency SUPPORTED_METHODS FIND_PACKAGE diff --git a/lockfile.json b/lockfile.json index 3a69ab1..787b905 100644 --- a/lockfile.json +++ b/lockfile.json @@ -4,7 +4,10 @@ "name": "googletest", "package_name": "GTest", "git_repository": "https://github.com/google/googletest.git", - "git_tag": "6910c9d9165801d8827d628cb72eb7ea9dd538c5" + "git_tag": "6910c9d9165801d8827d628cb72eb7ea9dd538c5", + "cmake_args": { + "INSTALL_GTEST": "OFF" + } } ] } diff --git a/port/portfile.cmake.in b/port/portfile.cmake.in new file mode 100644 index 0000000..948f51e --- /dev/null +++ b/port/portfile.cmake.in @@ -0,0 +1,28 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO bemanproject/transform_view + REF "v@VERSION@" + SHA512 @SHA512@ + HEAD_REF main +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBEMAN_TRANSFORM_VIEW_BUILD_TESTS=OFF + -DBEMAN_TRANSFORM_VIEW_BUILD_EXAMPLES=OFF +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup( + PACKAGE_NAME beman.transform_view + CONFIG_PATH lib/cmake/beman.transform_view +) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug" + "${CURRENT_PACKAGES_DIR}/lib" +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/port/vcpkg.json.in b/port/vcpkg.json.in new file mode 100644 index 0000000..0d06eb0 --- /dev/null +++ b/port/vcpkg.json.in @@ -0,0 +1,17 @@ +{ + "name": "beman-transform-view", + "version-semver": "@VERSION@", + "description": "A conditionally borrowed std::ranges::transform_view", + "homepage": "https://github.com/bemanproject/transform_view", + "license": "Apache-2.0 WITH LLVM-exception", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/tests/beman/transform_view/CMakeLists.txt b/tests/beman/transform_view/CMakeLists.txt index c655d2d..39360df 100644 --- a/tests/beman/transform_view/CMakeLists.txt +++ b/tests/beman/transform_view/CMakeLists.txt @@ -13,4 +13,7 @@ target_link_libraries( ) include(GoogleTest) -gtest_discover_tests(beman.transform_view.tests.transform_view) +gtest_discover_tests( + beman.transform_view.tests.transform_view + DISCOVERY_TIMEOUT 60 +) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..25169b2 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,15 @@ +{ + "default-registry": { + "kind": "git", + "repository": "https://github.com/microsoft/vcpkg.git", + "baseline": "80f9bcfa455e875d9c1bf7a7c6692d7e1e481061" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/bemanproject/vcpkg-registry.git", + "baseline": "5195f94f2b550163917c1152180fc59bbd760556", + "packages": ["beman-*"] + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..9506b66 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "beman-transform-view", + "version-semver": "0.1.0", + "dependencies": [ + { + "name": "gtest", + "host": true + } + ] +}