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.
  • Loading branch information
Ortham committed Jan 15, 2025
1 parent 1e57ea1 commit 95a89ac
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
54 changes: 40 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,27 @@ jobs:
LIBLOOT_SAFE_DESC_REF=${LIBLOOT_DESC_REF//[\/<>\"|]/_}
echo "version=$LIBLOOT_SAFE_DESC_REF" >> $GITHUB_OUTPUT
- name: Download Boost
id: get-boost
- name: Get Boost metadata
id: boost-metadata
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
BOOST_ROOT="${{ github.workspace }}/boost_${BOOST_VERSION//./_}"
echo "root=$BOOST_ROOT" >> $GITHUB_OUTPUT
echo "root=${BOOST_BASENAME}" >> $GITHUB_OUTPUT
- name: Boost cache
id: boost-cache
uses: actions/cache@v4
with:
path: |
${{ steps.boost-metadata.outputs.root }}/boost
${{ steps.boost-metadata.outputs.root }}/stage
key: ${{ runner.os }}-Boost-${{ env.BOOST_VERSION }}

# Need to build Boost's 'system' stub to generate the CMake config file.
- name: Download & build 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 $BOOST_VERSION -a 64 system
if: steps.boost-cache.outputs.cache-hit != 'true'

- name: Install APT package dependencies
run: |
Expand All @@ -64,7 +77,7 @@ jobs:
- name: Run CMake
run: |
cmake \
-DBOOST_ROOT="${{ steps.get-boost.outputs.root }}" \
-DCMAKE_PREFIX_PATH="${{ steps.boost-metadata.outputs.root }}\stage" \
-DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" \
-B build
cmake --build build
Expand Down Expand Up @@ -138,14 +151,27 @@ jobs:
- name: Install Rust i686-pc-windows-msvc target
run: rustup target add i686-pc-windows-msvc

- name: Download Boost
id: get-boost
- name: Get Boost metadata
id: boost-metadata
run: |
$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"
$BOOST_ROOT="${{ github.workspace }}/boost_" + $env:BOOST_VERSION -replace "\.", "_"
echo "root=$BOOST_ROOT" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "root=$BOOST_BASENAME" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Boost cache
id: boost-cache
uses: actions/cache@v4
with:
path: |
${{ steps.boost-metadata.outputs.root }}/boost
${{ steps.boost-metadata.outputs.root }}/stage
key: ${{ runner.os }}-x64-Boost-${{ env.BOOST_VERSION }}

# Need to build Boost's 'system' stub to generate the CMake config file.
- name: Download & build 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
if: steps.boost-cache.outputs.cache-hit != 'true'

- name: Get descriptive libloot version
id: get-libloot-version
Expand All @@ -160,7 +186,7 @@ jobs:
run: |
cmake -G "Visual Studio 16 2019" `
-A ${{ matrix.platform }} `
-DBOOST_ROOT="${{ steps.get-boost.outputs.root }}" `
-DCMAKE_PREFIX_PATH="${{ steps.boost-metadata.outputs.root }}\stage" `
-DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" `
-B build
cmake --build build --config ${{ env.MSVC_CONFIG }}
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,23 @@ 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: Run CMake
run: |
cmake -G "Visual Studio 16 2019" `
-A ${{ matrix.platform }} `
-DBOOST_ROOT="${{ steps.get-boost.outputs.root }}" `
-DCMAKE_PREFIX_PATH="${{ steps.get-boost.outputs.root }}\stage" `
-DCPACK_PACKAGE_VERSION="${{ needs.create_release.outputs.git_tag }}" `
-B build
cmake --build build --config ${{ env.MSVC_CONFIG }}
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 95a89ac

Please sign in to comment.