diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0a14f4ce4..f316ca1e6 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -18,7 +18,22 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - run: ./scripts/build-cmake-integration-tests.sh - - run: + - name: Install Ninja + uses: ./.github/actions/install-ninja + - name: Install boost + uses: ./.github/actions/install-boost + id: install-boost + with: + platform_version: "22.04" + - name: Install OpenSSL + uses: ./.github/actions/install-openssl + id: install-openssl + - run: ./scripts/configure-cmake-integration-tests.sh + env: + # Note: these are consumed by the SDK's CMake project, and then will be passed into the cmake integration tests + # so that the test projects will know where to find Boost and OpenSSL. More info in the README. + BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} + OPENSSL_ROOT_DIR: ${{ steps.install-openssl.outputs.OPENSSL_ROOT_DIR }} + - run: | export CTEST_OUTPUT_ON_FAILURE=1 cd build/cmake-tests && ctest diff --git a/cmake-tests/README.md b/cmake-tests/README.md index ac7acb5b2..1729fa2d2 100644 --- a/cmake-tests/README.md +++ b/cmake-tests/README.md @@ -51,11 +51,11 @@ Without setting these, the test would fail to build with the same compilers as t Additionally, certain variables must be forwarded to each test project CMake configuration. -| Variable | Explanation | -|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------| -| `BOOST_LIBRARY`/`BOOST_INCLUDE_DIR` | Windows build uses Boost downloaded at runtime, there's no system Boost. | -| `OPENSSL_LIBRARY`/`OPENSSL_INCLUDE_DIR` | Windows build uses OpenSSL downloaded at runtime. | -| `CMAKE_GENERATOR_PLATFORM` | Windows build explicitly specifies x64 build, whereas the default project build would be x86. Linker errors would ensue. | +| Variable | Explanation | +|----------------------------|--------------------------------------------------------------------------------------------------------------------------| +| `BOOST_ROOT` | Path to Boost. | +| `OPENSSL_ROOT_DIR` | Path to OpenSSL. | +| `CMAKE_GENERATOR_PLATFORM` | Windows build explicitly specifies x64 build, whereas the default project build would be x86. Linker errors would ensue. | The creation logic uses a series of CMake generator expressions (`$<...>`) to forward the variables in the table above from the main SDK project (which `add_subdirectory`'d each test) to the test projects. @@ -73,33 +73,3 @@ The generator expressions omit the `-D` entirely if the original variable is emp Checks that a project can include the SDK as a sub-project, via `add_subdirectory`. This would be a likely use-case when the repo is a submodule of another project. - -### cmake_projects/test_find_package - -Checks that a project can include the SDK via `find_package(ldserverapi)`. -This would be a likely use-case if the SDK was installed on the system by the user. - -**NOTE:** Requires SDK to be installed. - -### cmake_projects/test_find_package_cpp - -Checks that a C++ project can include the SDK via `find_package(ldserverapi)`. -Also checks that C++ bindings can be included without compilation issues. - -**NOTE:** Requires SDK to be installed. - -### cmake_projects/test_find_package_compatible_version - -Checks that a project can include the SDK via `find_package(ldserverapi [version])`. -This would be a likely use-case if the user depends on a particular version of the SDK, -rather than accepting any version. - -**NOTE:** Requires SDK to be installed. - -### cmake_projects/test_find_package_incompatible_version - -Checks that a project will *fail* to configure if `find_package(ldserverapi [version])` -is invoked with a version that isn't present on the system. The test uses a fictional -version `10.0.0`. - -**NOTE:** Requires SDK to be installed. diff --git a/cmake-tests/declareProjectTest.cmake b/cmake-tests/declareProjectTest.cmake index 3e6fbc299..f6f75b8fc 100644 --- a/cmake-tests/declareProjectTest.cmake +++ b/cmake-tests/declareProjectTest.cmake @@ -35,10 +35,8 @@ macro(declare_add_subdirectory_test name) -DBUILD_TESTING=OFF # Forward variables from the SDK project to the test project, if set. $<$:-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}> - $<$:-DBOOST_LIBRARY=${BOOST_LIBRARY}> - $<$:-DBOOST_INCLUDE_DIR=${BOOST_INCLUDE_DIR}> - $<$:-DOPENSSL_LIBRARY=${OPENSSL_LIBRARY}> - $<$:-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}> + $<$:-DBOOST_ROOT=${BOOST_ROOT}> + $<$:-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}> ${CMAKE_CURRENT_SOURCE_DIR}/project ) @@ -84,10 +82,8 @@ macro(declare_find_package_test name) -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX} # Forward variables from the SDK project to the test project, if set. $<$:-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}> - $<$:-DBOOST_LIBRARY=${BOOST_LIBRARY}> - $<$:-DBOOST_INCLUDE_DIR=${BOOST_INCLUDE_DIR}> - $<$:-DOPENSSL_LIBRARY=${OPENSSL_LIBRARY}> - $<$:-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}> + $<$:-DBOOST_ROOT=${BOOST_ROOT}> + $<$:-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}> ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/scripts/build-cmake-integration-tests.sh b/scripts/configure-cmake-integration-tests.sh similarity index 95% rename from scripts/build-cmake-integration-tests.sh rename to scripts/configure-cmake-integration-tests.sh index 3849e92ff..c4ad1562f 100755 --- a/scripts/build-cmake-integration-tests.sh +++ b/scripts/configure-cmake-integration-tests.sh @@ -16,5 +16,3 @@ cmake -G Ninja -D CMAKE_COMPILE_WARNING_AS_ERROR=TRUE \ -D BUILD_TESTING=ON \ -D LD_CMAKE_INTEGRATION_TESTS=ON \ -D LD_BUILD_EXAMPLES=OFF .. - -cmake --build .