Skip to content

Commit

Permalink
Update minimal CMake version to 1.19
Browse files Browse the repository at this point in the history
This simplifies supporting Python package build script and works for
Apple Silicon.
  • Loading branch information
vsbogd committed May 24, 2024
1 parent f28d5b0 commit c14c8ca
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
with:
python-version: "3.7"
os: "ubuntu-20.04"
cmake-version: "3.16.x"
cmake-version: "3.19.x"
2 changes: 1 addition & 1 deletion .github/workflows/ci-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
cmake-version:
description: 'JSON array of CMake versions to be checked'
required: true
default: "[\"3.15.x\"]"
default: "[\"3.19.x\"]"
type: string

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
type: string
cmake-version:
description: "CMake version to use"
default: "3.16.x"
default: "3.19.x"
required: false
type: string

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Install CMake
uses: jwlawson/[email protected]
with:
cmake-version: "3.16.x"
cmake-version: "3.19.x"

- name: Install Conan
uses: turtlebrowser/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimal version supported by hyperonc
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.19)

project(hyperon)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Rust (see the Notes at the installation page).
* Python3 and Python3-dev (3.7 or later)
* Pip (23.1.2 or later)
* GCC (7.5 or later)
* CMake (3.15 or later)
* CMake (3.19 or later)

* Install cbindgen:
```
Expand Down
4 changes: 2 additions & 2 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimal version which allows building dependencies from sources
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.19)
project(hyperonc)

enable_testing()
Expand All @@ -9,7 +9,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
execute_process(
# --build is required to build dependencies from source under cibuildwheel
# environment
COMMAND cmake -E env CC= CXX= conan install --build -- ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND cmake -E env CC= CXX= conan install --build -pr:b default -pr:h default -- ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
Expand Down
34 changes: 8 additions & 26 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# version supported by Ubuntu 18.04
cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.19)
project(hyperonpy)

enable_testing()
Expand All @@ -11,31 +10,14 @@ if (POLICY CMP0025)
endif ()
set(CMAKE_CXX_STANDARD 11)

if (${CMAKE_VERSION} GREATER_EQUAL "3.12")
# The default value ("FIRST") prefers the installation with the highest
# version. "ONLY" sticks to a virtualenv even when its version is smaller
# which is usually expected by an user.
if (NOT DEFINED Python3_FIND_VIRTUALENV)
set(Python3_FIND_VIRTUALENV "ONLY")
endif()
if (${CMAKE_VERSION} GREATER_EQUAL "3.18")
# Development.Embed is not supported by cibuildwheel environment
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development.Module)
else()
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development)
endif()
else() # support Ubuntu 18.04
# pybind11 config looks for Python path again when deprecated PythonInterp
# and PythonLibs packages are used. It should find the same version though
# because PYTHON_EXECUTABLE is already set.
find_package(PythonInterp 3.7 REQUIRED)
find_package(PythonLibs 3.7 REQUIRED)
# Python installation path should be modified via Python environment.
# Following way of getting paths seems to be working (for Ubuntu as well).
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'), end='')" OUTPUT_VARIABLE Python3_SITEARCH)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('purelib'), end='')" OUTPUT_VARIABLE Python3_SITELIB)
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
# The default value ("FIRST") prefers the installation with the highest
# version. "ONLY" sticks to a virtualenv even when its version is smaller
# which is usually expected by an user.
if (NOT DEFINED Python3_FIND_VIRTUALENV)
set(Python3_FIND_VIRTUALENV "ONLY")
endif()
# Development.Embed is not supported by cibuildwheel environment
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development.Module)
message(STATUS "Python native modules installation path (Python3_SITEARCH): ${Python3_SITEARCH}")
message(STATUS "Python modules installation path (Python3_SITELIB): ${Python3_SITELIB}")

Expand Down

0 comments on commit c14c8ca

Please sign in to comment.