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
34 changes: 33 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# (BUILD_SHARED_LIBS). Also with the sanitizers, with -Wall -Wextra -Werror,
# checking the headers it installs too (GAOL v5), with the minimum version of
# CMake GAOL declares, and as a part of another project, brought in by
# FetchContent (tests/fetch_content).
# FetchContent (tests/fetch_content). The test cpack_stale_configure also runs
# with ccache in CC and Ninja outside PATH.
#
# The runners have no locale writing a decimal comma, which tests/numbers.cpp
# reads and writes numbers under where there is one, and where there is none it
Expand Down Expand Up @@ -258,6 +259,37 @@ jobs:
- name: The test numbers ran under a locale writing a decimal comma
run: sh .github/scripts/comma-locale.sh check build

# The test cpack_stale_configure configures copies of the tree with the
# compilers and the generator that configured GAOL: with a compiler given
# with an argument, which CMake keeps in CMAKE_C_COMPILER_ARG1, and Ninja
# outside PATH, where CMake finds it by CMAKE_MAKE_PROGRAM only. The test
# needs no build (GAOL v5)
launcher-ninja:
name: Ubuntu 24.04 x86_64 GCC, cpack_stale_configure with ccache in CC and Ninja outside PATH
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- name: ccache, and Ninja outside PATH
run: |
sudo apt-get update -q
sudo apt-get install -y -q ccache
curl -sSL -o "$RUNNER_TEMP/ninja-linux.zip" https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
unzip -q "$RUNNER_TEMP/ninja-linux.zip" -d "$RUNNER_TEMP/ninja"
# A Ninja of the image, under the names CMake looks for in PATH
for name in ninja-build ninja samu; do
for program in $(which -a "$name"); do sudo rm -f "$program"; done
if command -v "$name"; then exit 1; fi
done
- name: Configure
run: CC="ccache gcc" CXX="ccache g++" cmake -S . -B build -G Ninja -DCMAKE_MAKE_PROGRAM="$RUNNER_TEMP/ninja/ninja" -DWITH_TESTS=ON
- name: The test cpack_stale_configure, which has to run, not be skipped
run: |
cd build
ctest -R cpack_stale_configure --no-tests=error > ctest.log 2>&1 || { cat ctest.log; exit 1; }
cat ctest.log
if grep -q Skipped ctest.log; then exit 1; fi

fetch-content:
name: Ubuntu 24.04 x86_64 GCC, GAOL built by FetchContent
runs-on: ubuntu-24.04
Expand Down
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,12 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# The archive of the sources: the files of the repository, without what git
# ignores (.gitignore), the builds within the sources, the packages, and the
# notes of the work on GAOL v5 (TODO.md, process.md, todo-notes/), which
# serve its maintainers, not the users of a version
# serve its maintainers, not the users of a version. CPack writes the CPACK_*
# variables into CPackConfig.cmake and CPackSourceConfig.cmake, which it reads
# when it runs: CPACK_VERBATIM_VARIABLES has it escape them, so that the
# backslashes of these regular expressions reach it as they are, where CMake
# 3 warned of an invalid escape sequence, \. (CMP0010, GAOL v5)
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "gaol-${PROJECT_VERSION}")
string(REGEX REPLACE "([][+.*()^$?|\\])" "\\\\\\1" _gaol_source_regex "${PROJECT_SOURCE_DIR}")
Expand All @@ -958,7 +963,15 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# warn while it configures only, so it does here, whether or not the archive
# is made. A tree without configure, or with a configure that has no such
# line, has nothing to compare (tests/cpack_stale_configure.cmake checks it,
# GAOL v5).
# GAOL v5). As the archive takes its name from the version CMake read when it
# configured, CPack includes cmake/gaol_package_source.cmake, which configures
# the build directory again first when VERSION.txt holds another version:
# Ninja does before package_source, the Makefile generators did not.
set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_SOURCE_DIR}/cmake/gaol_package_source.cmake")
set(CPACK_GAOL_VERSION "${PROJECT_VERSION}")
set(CPACK_GAOL_CMAKE_COMMAND "${CMAKE_COMMAND}")
set(CPACK_GAOL_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(CPACK_GAOL_BINARY_DIR "${PROJECT_BINARY_DIR}")
if(EXISTS "${PROJECT_SOURCE_DIR}/configure")
file(STRINGS "${PROJECT_SOURCE_DIR}/configure" _gaol_configure_version REGEX "^PACKAGE_VERSION='" LIMIT_COUNT 1)
if(_gaol_configure_version MATCHES "^PACKAGE_VERSION='([^']*)'")
Expand Down
48 changes: 48 additions & 0 deletions cmake/gaol_package_source.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ==================================================================
# The archive of the sources after a change of VERSION.txt (GAOL v5)
# ==================================================================
#
# CPack includes this file when it makes a package, once per generator
# (CPACK_PROJECT_CONFIG_FILE, set by CMakeLists.txt). The archive of the
# sources (package_source) takes its name and its version from
# CPackSourceConfig.cmake, which CMake writes in the build directory when it
# configures. Before package_source, Ninja configures again after a change of
# VERSION.txt (CMAKE_CONFIGURE_DEPENDS), but the Makefile generators run CPack
# at once: the archive was named after the old version, held the new
# VERSION.txt, and CMake did not say whether configure had been generated for
# it. So when VERSION.txt holds another version than the build directory was
# configured for, CMake configures it again here, which warns of a configure
# generated for another version, and the configuration it writes again is read
# in place of the old one. Only for the archive of the sources: the target
# package builds first, which configures again with every generator.
#
# Copyright (c) 2026 ENSTA, France
#
# Created 2026-10-06 by Jordan NININ

# CPack reads this file without the policies of CMakeLists.txt: CMake 3 would
# warn of CMP0007 at the list() of gaol_read_version() otherwise
cmake_policy(PUSH)
cmake_policy(VERSION 3.14...3.25)

# CPack sets CPACK_INSTALLED_DIRECTORIES for the archive of the sources only:
# the packages of the library install the build instead. The version compared
# is GAOL's own, CPACK_PACKAGE_VERSION being that of cpack -R when it is given
if(CPACK_INSTALLED_DIRECTORIES)
include("${CPACK_GAOL_SOURCE_DIR}/cmake/gaol_version.cmake")
gaol_read_version("${CPACK_GAOL_SOURCE_DIR}/VERSION.txt" _gaol_version _gaol_version_error)
# A VERSION.txt refused configures again too, which fails with its message
if(NOT _gaol_version STREQUAL CPACK_GAOL_VERSION)
message(STATUS "VERSION.txt no longer holds ${CPACK_GAOL_VERSION}, the version "
"${CPACK_GAOL_BINARY_DIR} was configured for: CMake configures it again")
execute_process(
COMMAND "${CPACK_GAOL_CMAKE_COMMAND}" -S "${CPACK_GAOL_SOURCE_DIR}" -B "${CPACK_GAOL_BINARY_DIR}"
RESULT_VARIABLE _gaol_status)
if(NOT _gaol_status EQUAL 0)
message(FATAL_ERROR "CMake did not configure ${CPACK_GAOL_BINARY_DIR} again (status ${_gaol_status})")
endif()
include("${CPACK_SOURCE_OUTPUT_CONFIG_FILE}")
endif()
endif()

cmake_policy(POP)
8 changes: 5 additions & 3 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ cmake --build build --target package

The archive takes its name from the version CMake read when it configured, and
CMake warns of a `configure` generated for another version at that moment.
After a change of `VERSION.txt`, configure the build directory again
(`cmake -S . -B build`) before `package_source`: Ninja does it by itself, the
Makefile generators do not.
After a change of `VERSION.txt`, `package_source` configures the build
directory again first, whatever the generator: Ninja does before it runs CPack,
and CPack does when `VERSION.txt` holds another version than the build
directory was configured for (`cmake/gaol_package_source.cmake`, GAOL v5),
where the Makefile generators ran CPack at once.

The packages hold `libgaol` as the build compiled it: with `GAOL_FMA` `ON`,
the default, only the processors that have the fused multiply-add
Expand Down
4 changes: 3 additions & 1 deletion doc/continuous-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ request (GAOL v5); `workflow_dispatch` runs them on any branch. The badges of
with the compilers of Ubuntu 22.04 (GCC 11 and Clang 14 on x86_64, GCC 11
on arm64), whose images GitHub retires by April 2027, with GCC 9, which has
no `__builtin_roundeven()` (see [3rd/README.md](../3rd/README.md)), and as a
shared library (`BUILD_SHARED_LIBS`).
shared library (`BUILD_SHARED_LIBS`); the test `cpack_stale_configure` also
runs with `CC="ccache gcc"` and a Ninja outside `PATH`, which it has to pass
on to the copies of the tree it configures.
- **Linux containers:**
- Debian 12 and 13 on amd64, arm64 and armhf, and Debian 12 on i386;
- manylinux_2_28 on x86_64 and aarch64;
Expand Down
45 changes: 32 additions & 13 deletions doc/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,19 +700,38 @@ mode there.
itself, where the tree has a `configure`): a script, not a program
(`tests/cpack_stale_configure.cmake`). CPack puts `configure` in the archive
of the sources as it is committed, and `configure --version` gives the version
it was generated for: after a change of `VERSION.txt` without a new
generation of `configure`, the archive of the new version holds a
`configure` that says the old one. The script configures copies of the tree
with the compiler that built GAOL, and CMake has to warn of it, naming the
two versions, whether `configure` has the line ends of Unix or of Windows,
and not otherwise: not when `configure` was generated for the version
`VERSION.txt` holds, not when it has no line `PACKAGE_VERSION=`, and not
when there is no `configure`, which CMake has to configure all the same. The
version `configure` was generated for is asked of `configure --version`, not
read as `CMakeLists.txt` reads it. The copies are made of symbolic links to
the files of the tree, but for `CMakeLists.txt`, `VERSION.txt` and
`configure`, which are copied; the test takes a few seconds on an ordinary
machine, a configuration and four that reuse its checks (GAOL v5).
it was generated for: after a change of `VERSION.txt` without a new generation
of `configure`, the archive of the new version holds a `configure` that says
the old one. The script configures copies of the tree with the generator and
the compilers that built GAOL, and CMake has to warn of it, naming the two
versions, whether `configure` has the line ends of Unix or of Windows, and not
otherwise: not when `configure` was generated for the version `VERSION.txt`
holds, not when it has no line `PACKAGE_VERSION=`, and not when there is no
`configure`, which CMake has to configure all the same. Then a copy configured
for the version `configure` was generated for has its `VERSION.txt` changed,
and CPack, run as `package_source` runs it, has to configure it again, warn,
and name the archive after the new version
(`cmake/gaol_package_source.cmake`), which the Makefile generators did not do,
CMake giving no warning of its own meanwhile (CMake 3 warned of the
backslashes of `CPACK_SOURCE_IGNORE_FILES` in the configuration it writes for
CPack); the archive has to hold `keep.halo`, a file of the copy that these
regular expressions do not match, but would without their backslashes, as
CMake 4 read them without `CPACK_VERBATIM_VARIABLES`. The version `configure`
was generated for is asked of `configure --version`, not read as
`CMakeLists.txt` reads it. The copies are made of symbolic links to the files
of the tree, but for `CMakeLists.txt`, `VERSION.txt` and `configure`, which
are copied. The compilers are given to CMake as `CC` and `CXX` with their
arguments (`CC="ccache gcc"` leaves `ccache` in `CMAKE_C_COMPILER` and `gcc`
in `CMAKE_C_COMPILER_ARG1`), and the generator with its program
(`CMAKE_MAKE_PROGRAM`, for a Ninja outside `PATH`), which a job of
`.github/workflows/linux.yml` checks; without `sh`, or where the system makes
no symbolic link, the test says it is skipped. It takes a few seconds on an
ordinary machine, a configuration and five that reuse its checks, and an
archive: of the links themselves with CMake 3.28 and after (170 KB), of the
files of the directories they point to with CMake 3.14 and 3.16 (5.6 MB). Only
the CMake build has it: CPack makes the archive, and the autotools jobs of the
continuous integration compare `configure --version` with `VERSION.txt`
already (GAOL v5).
- **The unit tests of GAOL 4:** `arithmetic_operators` (`check/arithmetic.cpp`),
`assignment`, `constants`, `constructor`, `float_functions`,
`generic_functions`, `input_output`, `interval_functions`, `misc`,
Expand Down
3 changes: 2 additions & 1 deletion manual/v5/gaol.tex
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ \subsection{The archive of the sources and the packages}\label{sec:packages}
from a clean checkout, and holds \file{configure} as it was generated. CMake
warns, when it configures, if that was for another version than
\file{VERSION.txt} holds: \cmd{configure --version} would give the old one
in the archive;
in the archive. After a change of \file{VERSION.txt}, \code{package\_source}
configures the build directory again first, whatever the generator;
\item \code{package} gives \file{gaol-\var{version}-\var{system}.tar.gz},
what \cmd{cmake --install} installs, to extract anywhere, and on Linux
\file{libgaol-dev\_\var{version}\_\var{arch}.deb}, the same files in
Expand Down
27 changes: 19 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,32 @@ endif()
# The warning of the CPack block of CMakeLists.txt, when the configure that the
# archive of the sources holds was generated for another version than VERSION.txt
# holds (GAOL v5): not a program, a script that configures copies of the tree
# with the compiler that built GAOL (cpack_stale_configure.cmake). Only the CMake
# build makes the archive; the copies are made of symbolic links, so the script
# runs on the machine that builds, where the system has them, and it asks the
# configure of the tree its version, so there has to be one. The time limit is
# that of a few configurations, on a slow machine.
# with the compilers that built GAOL, and makes the archive after a change of
# VERSION.txt (cpack_stale_configure.cmake). Only the CMake build makes the
# archive; the copies are made of symbolic links, so the script runs on the
# machine that builds, and it asks the configure of the tree its version, so
# there has to be one. The compilers are passed with their arguments, which
# CMake keeps apart: with CC="ccache gcc", CMAKE_C_COMPILER is ccache and
# CMAKE_C_COMPILER_ARG1 gcc. Without sh, or on a system that makes no symbolic
# link, the script says it is skipped, which CTest reads from CMake 3.16 (the
# test passes before). The time limit is that of a few configurations, on a
# slow machine.
if(CMAKE_HOST_UNIX AND NOT CMAKE_CROSSCOMPILING AND EXISTS "${PROJECT_SOURCE_DIR}/configure")
foreach(_lang C CXX)
string(STRIP "${CMAKE_${_lang}_COMPILER_ARG1}" _gaol_arguments)
string(STRIP "${CMAKE_${_lang}_COMPILER} ${_gaol_arguments}" _gaol_${_lang}_compiler)
endforeach()
add_test(NAME cpack_stale_configure
COMMAND "${CMAKE_COMMAND}"
"-DGAOL_SOURCE_DIR=${PROJECT_SOURCE_DIR}"
"-DGAOL_WORK_DIR=${CMAKE_CURRENT_BINARY_DIR}/cpack_stale_configure"
"-DGAOL_GENERATOR=${CMAKE_GENERATOR}"
"-DGAOL_C_COMPILER=${CMAKE_C_COMPILER}"
"-DGAOL_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DGAOL_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
"-DGAOL_C_COMPILER=${_gaol_C_compiler}"
"-DGAOL_CXX_COMPILER=${_gaol_CXX_compiler}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cpack_stale_configure.cmake")
set_tests_properties(cpack_stale_configure PROPERTIES LABELS unit TIMEOUT 600)
set_tests_properties(cpack_stale_configure PROPERTIES LABELS unit TIMEOUT 600
SKIP_REGULAR_EXPRESSION "cpack_stale_configure: skipped")
endif()

# Commented out: the tests run no thread (GAOL v5)
Expand Down
Loading
Loading