Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,52 @@ jobs:
with:
workflowPreset: "${{ matrix.toolchain }}-ci"
continue-on-error: ${{ matrix.experimental && inputs.mask-experimental}}
cmake-version:
name: >
🔨 CMake ${{ matrix.cmake }}
${{ matrix.experimental && '[🧪 Experimental]' || '' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
cmake: [ "3.20", "latest", "latestrc" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for me: this is minimum required CMake version

include:
- cmake: latestrc
experimental: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
python3 -m pip install pip-tools
pip-compile --extra=test --strip-extras pyproject.toml ${{ matrix.pre && '--pre' }}
python3 -m pip install -r requirements.txt
- uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ matrix.cmake }}
- name: Run CMake workflow
uses: lukka/run-cmake@v10.3
with:
workflowPreset: gcc-ci
continue-on-error: ${{ matrix.experimental && inputs.mask-experimental}}
if: matrix.cmake != '3.20'
- name: Run CMake manually
# Need CMake 3.25 to properly use the presets
run: |
cmake -B ./build -G Ninja \
-DSPGLIB_WITH_Fortran=ON \
-DSPGLIB_WITH_TESTS=ON \
-DSPGLIB_WITH_Python=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_C_COMPILER=g++ \
-DCMAKE_C_COMPILER=gfortran
cmake --build ./build
ctest --test-dir ./build -j $(nproc) --output-on-failure
continue-on-error: ${{ matrix.experimental && inputs.mask-experimental}}
if: matrix.cmake == '3.20'
sanitizer:
name: >
🧹 ${{ matrix.sanitizer }} +
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ GitHub release pages and in the git history.
- [\[#425\]](https://github.com/spglib/spglib/pull/425) - Update to codecov v4
- [\[#402\]](https://github.com/spglib/spglib/pull/402) - Bump artifact actions to v4
- [\[#402\]](https://github.com/spglib/spglib/pull/402) - Build and inspect python sdist
- [\[#431\]](https://github.com/spglib/spglib/pull/431) - Test CMake versions

## v2.3.1 (10 Feb. 2024)

Expand Down
26 changes: 19 additions & 7 deletions fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,25 @@ set(external_libs)
include(FetchContent)

# Get Spglib if it's run as stand-alone project
if (NOT Spglib_IS_TOP_LEVEL)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
if (NOT Spglib_SOURCE_DIR)
if (CMAKE_VERSION VERSION_LESS 3.24)
# TODO: Use by default when minimum is CMake 3.24
find_package(Spglib CONFIG QUIET)
if (NOT Spglib_FOUND)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
)
list(APPEND external_libs Spglib)
endif ()
else ()
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
endif ()
endif ()
FetchContent_MakeAvailable(${external_libs})

Expand Down
26 changes: 19 additions & 7 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,25 @@ set(external_libs)
include(FetchContent)

# Get Spglib if it's run as stand-alone project
if (NOT Spglib_IS_TOP_LEVEL)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
if (NOT Spglib_SOURCE_DIR)
if (CMAKE_VERSION VERSION_LESS 3.24)
# TODO: Use by default when minimum is CMake 3.24
find_package(Spglib CONFIG QUIET)
if (NOT Spglib_FOUND)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
)
list(APPEND external_libs Spglib)
endif ()
else ()
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
endif ()
endif ()
find_package(Python 3.8 COMPONENTS REQUIRED Interpreter Development.Module NumPy)
FetchContent_MakeAvailable(${external_libs})
Expand Down
35 changes: 28 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,34 @@ endif ()
set(external_libs)
include(FetchContent)

# Get Spglib if it's run as stand-alone project
if (NOT Spglib_IS_TOP_LEVEL)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
set(fetchcontent_extra_args)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
# TODO: Use by default when minimum is CMake 3.24
list(APPEND fetchcontent_extra_args
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
endif ()

# Get Spglib if it's run as stand-alone project
if (NOT Spglib_SOURCE_DIR)
if (CMAKE_VERSION VERSION_LESS 3.24)
# TODO: Use by default when minimum is CMake 3.24
find_package(Spglib CONFIG QUIET)
if (NOT Spglib_FOUND)
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
)
list(APPEND external_libs Spglib)
endif ()
else ()
FetchContent_Declare(Spglib
GIT_REPOSITORY https://github.com/spglib/spglib
GIT_TAG develop
FIND_PACKAGE_ARGS CONFIG
)
list(APPEND external_libs Spglib)
endif ()
endif ()

set(BUILD_GMOCK OFF)
Expand All @@ -89,7 +109,8 @@ set(gtest_disable_pthreads ON)
FetchContent_Declare(GTest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.13.0
FIND_PACKAGE_ARGS CONFIG
# For CMake < 3.24, always download GTest. Packaging for CMake <3.24 is unsupported
${fetchcontent_extra_args}
)
list(APPEND external_libs GTest)

Expand Down
8 changes: 6 additions & 2 deletions test/functional/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ create_test_sourcelist(FortranTests_Files
test_fortran_version.F90
)

# CMake < 3.29 includes the driver source in the source list
list(REMOVE_ITEM FortranTests_Files fortran_test.c)
target_sources(Spglib_Fortran_tests PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/fortran_test.c
Expand All @@ -65,8 +66,11 @@ target_compile_definitions(Spglib_Fortran_tests PRIVATE

# Loop over all main tests files
foreach (test IN LISTS FortranTests_Files)
# TODO: CMake 3.20 Switch to cmake_path
get_filename_component(test_name ${test} NAME_WE)
if (test MATCHES ".*fortran_test.*")
# Skip the test driver
continue()
endif ()
cmake_path(REMOVE_EXTENSION test OUTPUT_VARIABLE test_name)
# Check if we have subtests defined
if (DEFINED SubTests_${test_name})
# Loop over all subtests
Expand Down