From 03bcf1317343b59cdc46b4b2b044f08290013b5b Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 8 Jul 2024 08:42:27 +0200 Subject: [PATCH 1/2] CMake: Set CMP0167 see https://cmake.org/cmake/help/latest/policy/CMP0167.html Closes #2476 --- CMakeLists.txt | 4 ++++ swig/CMakeLists_model.cmake | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b0374b3a9..aaa0b39810 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,10 @@ cmake_policy(VERSION 3.15...3.27) if(POLICY CMP0144) cmake_policy(SET CMP0144 NEW) endif(POLICY CMP0144) +# cmake >= 3.30 +if(POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif(POLICY CMP0167) project(amici) diff --git a/swig/CMakeLists_model.cmake b/swig/CMakeLists_model.cmake index eb9fe681c9..523571c52e 100644 --- a/swig/CMakeLists_model.cmake +++ b/swig/CMakeLists_model.cmake @@ -1,4 +1,15 @@ cmake_minimum_required(VERSION 3.15) +cmake_policy(VERSION 3.15...3.27) + +# cmake >=3.27 +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif(POLICY CMP0144) +# cmake >= 3.30 +if(POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif(POLICY CMP0167) + if(DEFINED ENV{SWIG}) set(SWIG_EXECUTABLE $ENV{SWIG}) From 6e3081aabd9048dbb3470b4f17cf113149d89bc2 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 8 Jul 2024 08:57:11 +0200 Subject: [PATCH 2/2] GHA: -Werror only for amici repo We have a couple of -Werror options enabled when running on GHA. However, we should also check for the repo name. If amici is used in tests of any downstream projects, we don't want errors. Also use CMake's `-Wno-dev` for non-amici-ci installations. --- python/sdist/setup.py | 4 +++- scripts/buildAmici.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/sdist/setup.py b/python/sdist/setup.py index 9dd268953a..d01a0ec75c 100755 --- a/python/sdist/setup.py +++ b/python/sdist/setup.py @@ -152,7 +152,9 @@ def get_extensions(): cmake_configure_options=[ *global_cmake_configure_options, "-Werror=dev" - if "GITHUB_ACTIONS" in os.environ + # Turn warnings in to errors on GitHub Actions, + # match original repo and forks with default name + if os.environ.get("GITHUB_REPOSITORY", "").endswith("/AMICI") else "-Wno-error=dev", "-DAMICI_PYTHON_BUILD_EXT_ONLY=ON", f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}", diff --git a/scripts/buildAmici.sh b/scripts/buildAmici.sh index cb2428579c..22faece983 100755 --- a/scripts/buildAmici.sh +++ b/scripts/buildAmici.sh @@ -13,7 +13,7 @@ amici_build_dir="${amici_path}/build" mkdir -p "${amici_build_dir}" cd "${amici_build_dir}" -if [ "${GITHUB_ACTIONS:-}" = true ] || +if [[ "${GITHUB_REPOSITORY:-}" = *"/AMICI" ]] || [ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ] || [ "${ENABLE_GCOV_COVERAGE:-}" = TRUE ]; then # Running on CI server