Skip to content

Commit

Permalink
Adapt build to CMake's CMP0167 policy
Browse files Browse the repository at this point in the history
This is a little awkward because libloot only needs Boost's headers, but it doesn't supply a CMake config unless it's built, so we build the system stub to make that happen as quickly as possible.

Also take the opportunity to run ctest in CI.
  • Loading branch information
Ortham committed Jan 15, 2025
1 parent 1a6d17d commit 991a599
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ jobs:
LIBLOOT_SAFE_DESC_REF=${LIBLOOT_DESC_REF//[\/<>\"|]/_}
echo "version=$LIBLOOT_SAFE_DESC_REF" >> $GITHUB_OUTPUT
# Need to build Boost's 'system' stub to generate the CMake config file.
- name: Download Boost
id: get-boost
run: |
BOOST_BASENAME=boost_${BOOST_VERSION//./_}
wget https://archives.boost.io/release/${BOOST_VERSION}/source/${BOOST_BASENAME}.tar.gz
tar -xf ${BOOST_BASENAME}.tar.gz
curl -sSfLO https://raw.githubusercontent.com/Ortham/ci-scripts/2.2.1/install_boost.py
echo "root=${BOOST_BASENAME}" >> $GITHUB_OUTPUT
python install_boost.py --directory ${{ github.workspace }} --boost-version ${{ env.BOOST_VERSION }} -a 64 system
echo "root=${{ github.workspace }}/boost_${BOOST_VERSION//./_}" >> $GITHUB_OUTPUT
- name: Install APT package dependencies
run: |
Expand All @@ -63,16 +64,14 @@ jobs:
- name: Run CMake
run: |
mkdir build
cd build
cmake .. -DBOOST_ROOT="${{ steps.get-boost.outputs.root }}" -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}"
make all
cmake \
-DCMAKE_PREFIX_PATH="${{ steps.get-boost.outputs.root }}\stage" \
-DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" \
-B build
cmake --build build
- name: Run tests
run: |
cd build
./libloot_internals_tests
./libloot_tests
run: ctest --test-dir build

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -140,14 +139,17 @@ jobs:
- name: Install Rust i686-pc-windows-msvc target
run: rustup target add i686-pc-windows-msvc

# Need to build Boost's 'system' stub to generate the CMake config file.
- name: Download Boost
id: get-boost
run: |
curl -sSfLO https://raw.githubusercontent.com/Ortham/ci-scripts/2.2.1/install_boost.py
python install_boost.py --directory ${{ github.workspace }} --boost-version ${{ env.BOOST_VERSION }} -a 64 system
$BOOST_BASENAME="boost_" + $env:BOOST_VERSION -replace "\.", "_"
curl -sSfLO "https://archives.boost.io/release/${env:BOOST_VERSION}/source/${BOOST_BASENAME}.7z"
7z x "${BOOST_BASENAME}.7z"
echo "root=$BOOST_BASENAME" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "root=${{ github.workspace }}/$BOOST_BASENAME" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Get descriptive libloot version
id: get-libloot-version
Expand All @@ -160,16 +162,15 @@ jobs:
- name: Run CMake
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DBOOST_ROOT="${{ steps.get-boost.outputs.root }}" -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}"
cmake --build . --config ${{ env.MSVC_CONFIG }}
cmake -G "Visual Studio 16 2019" \
-A ${{ matrix.platform }} \
-DCMAKE_PREFIX_PATH="${{ steps.get-boost.outputs.root }}\stage" \
-DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" \
-B build
cmake --build build --config ${{ env.MSVC_CONFIG }}
- name: Run tests
run: |
cd build/${{ env.MSVC_CONFIG }}
.\libloot_internals_tests.exe
.\libloot_tests.exe
run: ctest --test-dir build --build-config ${{ env.MSVC_CONFIG }}

- uses: actions/setup-python@v5
with:
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.24)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
project(libloot)
include(ExternalProject)
include(FetchContent)
Expand Down Expand Up @@ -46,6 +49,7 @@ configure_file("${CMAKE_SOURCE_DIR}/src/api/loot_version.cpp.in" "${CMAKE_BINARY
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED CONFIG)

if(NOT DEFINED RUST_TARGET AND WIN32)
if(MSVC)
Expand All @@ -72,8 +76,6 @@ else()
set(RUST_CLEANUP_COMMAND ${CMAKE_COMMAND} -E rm -r "target/release/build" "target/release/deps")
endif()

find_package(Boost REQUIRED)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(ICU REQUIRED COMPONENTS data uc)
find_package(TBB REQUIRED)
Expand Down

0 comments on commit 991a599

Please sign in to comment.