Skip to content

Commit 8a14cf7

Browse files
authored
Fix find_package(Boost) for CMake 4.x (AcademySoftwareFoundation#507)
find_package(Boost) has changed under CMake 3.26+: CMake Warning (dev) at src/python/CMakeLists.txt:16 (find_package): Policy CMP0167 is not set: The FindBoost module is removed. Run "cmake --help-policy CMP0167" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. The fix is to include `CONFIG`: find_package(Boost CONFIG REQUIRED COMPONENTS python) This also adds a CI test for cmake 4.0.3. Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent 857e389 commit 8a14cf7

5 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/ci_steps.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,31 @@ jobs:
227227
shell: bash
228228

229229
- name: Install CMake
230-
if: runner.os == 'Linux' && inputs.cmake != ''
231230
# CMakeLists.txt specifies a minimum CMake version of 3.14 for
232-
# the Imath project, so use that for the CI. Except that the
233-
# conan toolchain requires a minimum of 3.15, so use that for
234-
# the runs that require conan.
231+
# the Imath project, so use that for the CI, unless a specific
232+
# version is specified. The conan toolchain requires a minimum
233+
# of 3.15, so use that for the runs that require conan.
235234
run: |
236-
CMAKE_VERSION=${{ inputs.cmake }}
237-
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
238-
tar -xzf cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
239-
echo "CMAKE=$PWD/cmake-$CMAKE_VERSION-Linux-x86_64/bin/cmake" >> $GITHUB_ENV
235+
set -ex
236+
CMAKE=cmake
237+
CTEST=ctest
238+
if [ "${{ inputs.cmake }}" != "" ]; then
239+
if [ "$RUNNER_OS" == "Linux" ]; then
240+
CMAKE_VERSION=${{ inputs.cmake }}
241+
CURRENT_CMAKE_VERSION=$(cmake --version | head -n 1 | cut -f3 -d' ')
242+
if [ "$CMAKE_VERSION" != "$CURRENT_CMAKE_VERSION" ]; then
243+
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
244+
tar -xzf cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
245+
CMAKE=$(find "$PWD" -type f -path "*/bin/cmake" | head -n 1)
246+
CTEST=$(find "$PWD" -type f -path "*/bin/ctest" | head -n 1)
247+
fi
248+
else
249+
echo "Explicit cmake version only supported on Linux."
250+
exit 1
251+
fi
252+
fi
253+
echo CMAKE="$CMAKE" >> $GITHUB_ENV
254+
echo CTEST="$CTEST" >> $GITHUB_ENV
240255
shell: bash
241256

242257
- name: Construct CMake command
@@ -424,7 +439,7 @@ jobs:
424439
set -x
425440
export PATH="$IMATH_PATH:$PATH"
426441
export PYTHONPATH=$PYTHON_INSTALL_DIR
427-
ctest -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
442+
$CTEST -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
428443
shell: bash
429444

430445
- name: Test (msys2)
@@ -434,7 +449,7 @@ jobs:
434449
set -x
435450
export PATH="$IMATH_PATH:$PATH"
436451
export PYTHONPATH=$PYTHON_INSTALL_DIR
437-
ctest -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
452+
$CTEST -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
438453
shell: msys2 {0}
439454

440455
- name: Prepare install_manifest

.github/workflows/ci_workflow.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ jobs:
9595
cxx-compiler: clang++
9696
cc-compiler: clang
9797

98+
- build: 7
99+
label: cmake 4
100+
cmake: 4.0.3
101+
98102
macOS:
99103
name: 'macOS.${{ matrix.build}}: ${{ matrix.label }}'
100104
uses: ./.github/workflows/ci_steps.yml

src/pybind11/PyBindImath/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ if (IMATH_INSTALL)
129129
#
130130

131131
set(PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
132-
message(STATUS "installing ${PYBINDIMATH_MODULE} to ${PYTHON_INSTALL_DIR}")
132+
message(STATUS "installing ${PYBINDIMATH_MODULE_NAME} to ${PYTHON_INSTALL_DIR}")
133133

134134
else()
135135

136-
message(STATUS "installing ${PYBINDIMATH_MODULE} to ${PYTHON_INSTALL_DIR} (set externally)")
136+
message(STATUS "installing ${PYBINDIMATH_MODULE_NAME} to ${PYTHON_INSTALL_DIR} (set externally)")
137137

138138
endif()
139139

src/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if(NOT Python3_FOUND)
1313
message(FATAL_ERROR "Could not find Python")
1414
endif()
1515

16-
find_package(Boost REQUIRED COMPONENTS python)
16+
find_package(Boost CONFIG REQUIRED COMPONENTS python)
1717

1818
if(NOT Boost_FOUND)
1919
message(FATAL_ERROR "Could not find Boost")

src/python/PyImath/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ if (IMATH_INSTALL)
214214
#
215215

216216
set(PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
217-
message(STATUS "installing ${PYIMATH_MODULE} module to ${PYTHON_INSTALL_DIR}")
217+
message(STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR}")
218218

219219
else()
220220

221-
message(STATUS "installing ${PYIMATH_MODULE} module to ${PYTHON_INSTALL_DIR} (set externally)")
221+
message(STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR} (set externally)")
222222

223223
endif()
224224

0 commit comments

Comments
 (0)