Skip to content

Commit

Permalink
get build deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Oct 2, 2024
1 parent 3f323e4 commit cd925a1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 47 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 5 additions & 35 deletions cmake-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
12 changes: 4 additions & 8 deletions cmake-tests/declareProjectTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
$<$<BOOL:${CMAKE_GENERATOR_PLATFORM}>:-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}>
$<$<BOOL:${BOOST_LIBRARY}>:-DBOOST_LIBRARY=${BOOST_LIBRARY}>
$<$<BOOL:${BOOST_INCLUDE_DIR}>:-DBOOST_INCLUDE_DIR=${BOOST_INCLUDE_DIR}>
$<$<BOOL:${OPENSSL_LIBRARY}>:-DOPENSSL_LIBRARY=${OPENSSL_LIBRARY}>
$<$<BOOL:${OPENSSL_INCLUDE_DIR}>:-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}>
$<$<BOOL:${BOOST_ROOT}>:-DBOOST_ROOT=${BOOST_ROOT}>
$<$<BOOL:${OPENSSL_ROOT_DIR}>:-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}>
${CMAKE_CURRENT_SOURCE_DIR}/project
)

Expand Down Expand Up @@ -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.
$<$<BOOL:${CMAKE_GENERATOR_PLATFORM}>:-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}>
$<$<BOOL:${BOOST_LIBRARY}>:-DBOOST_LIBRARY=${BOOST_LIBRARY}>
$<$<BOOL:${BOOST_INCLUDE_DIR}>:-DBOOST_INCLUDE_DIR=${BOOST_INCLUDE_DIR}>
$<$<BOOL:${OPENSSL_LIBRARY}>:-DOPENSSL_LIBRARY=${OPENSSL_LIBRARY}>
$<$<BOOL:${OPENSSL_INCLUDE_DIR}>:-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}>
$<$<BOOL:${BOOST_ROOT}>:-DBOOST_ROOT=${BOOST_ROOT}>
$<$<BOOL:${OPENSSL_ROOT_DIR}>:-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}>
${CMAKE_CURRENT_SOURCE_DIR}/project
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

0 comments on commit cd925a1

Please sign in to comment.