diff --git a/CMakeLists.txt b/CMakeLists.txt index 81cc70c9d0..4b0c95321b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,6 @@ if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}") else() add_compile_options(-O0 -g) endif() - set(CMAKE_BUILD_TYPE "Debug") endif() # coverage options diff --git a/python/sdist/amici/setup.template.py b/python/sdist/amici/setup.template.py index 80fd3fde2a..14edbfd2d4 100644 --- a/python/sdist/amici/setup.template.py +++ b/python/sdist/amici/setup.template.py @@ -24,6 +24,11 @@ def get_extension() -> CMakeExtension: else: os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = "1" + debug_build = os.getenv("ENABLE_AMICI_DEBUGGING", "").lower() in [ + "1", + "true", + ] or os.getenv("ENABLE_GCOV_COVERAGE", "").lower() in ["1", "true"] + return CMakeExtension( name="model_ext", source_dir=os.getcwd(), @@ -37,6 +42,7 @@ def get_extension() -> CMakeExtension: "-DAMICI_PYTHON_BUILD_EXT_ONLY=ON", f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}", ], + cmake_build_type="Debug" if debug_build else "Release", ) diff --git a/python/sdist/pyproject.toml b/python/sdist/pyproject.toml index 10a3b05374..905e564cf4 100644 --- a/python/sdist/pyproject.toml +++ b/python/sdist/pyproject.toml @@ -11,7 +11,7 @@ requires = [ # cf. discussion at https://github.com/numpy/numpy/issues/5888 # (https://github.com/scipy/oldest-supported-numpy/) "oldest-supported-numpy", - "cmake-build-extension==0.5.1", + "cmake-build-extension==0.6.0", ] build-backend = "setuptools.build_meta" @@ -21,7 +21,7 @@ dynamic = ["version"] description = "Advanced multi-language Interface to CVODES and IDAS" requires-python = ">=3.10" dependencies = [ - "cmake-build-extension==0.5.1", + "cmake-build-extension==0.6.0", "sympy>=1.9", "numpy>=1.19.3; python_version=='3.9'", "numpy>=1.21.4; python_version>='3.10'", diff --git a/python/sdist/setup.py b/python/sdist/setup.py index 83bf33237a..9dd268953a 100755 --- a/python/sdist/setup.py +++ b/python/sdist/setup.py @@ -141,6 +141,10 @@ def get_extensions(): ], ) # AMICI + debug_build = os.getenv("ENABLE_AMICI_DEBUGGING", "").lower() in [ + "1", + "true", + ] or os.getenv("ENABLE_GCOV_COVERAGE", "").lower() in ["1", "true"] amici_ext = CMakeExtension( name="amici", install_prefix="amici", @@ -153,6 +157,7 @@ def get_extensions(): "-DAMICI_PYTHON_BUILD_EXT_ONLY=ON", f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}", ], + cmake_build_type="Debug" if debug_build else "Release", ) # Order matters! return [suitesparse_config, amd, btf, colamd, klu, sundials, amici_ext] diff --git a/python/tests/test_misc.py b/python/tests/test_misc.py index b68e96f1a0..80e1afaa03 100644 --- a/python/tests/test_misc.py +++ b/python/tests/test_misc.py @@ -65,8 +65,9 @@ def test_cmake_compilation(sbml_example_presimulation_module): amici_dir = (Path(__file__).parents[2] / "build").absolute() cmd = ( f"set -e; " - f"cmake -S {source_dir} -B '{build_dir}' -DAmici_DIR={amici_dir}; " - f"cmake --build '{build_dir}'" + f"cmake -S {source_dir} -B '{build_dir}' " + f"-DCMAKE_BUILD_TYPE=Debug -DAmici_DIR={amici_dir}; " + f"cmake --build '{build_dir}' --config Debug" ) try: diff --git a/scripts/buildAmici.sh b/scripts/buildAmici.sh index 80b724c8c3..cb2428579c 100755 --- a/scripts/buildAmici.sh +++ b/scripts/buildAmici.sh @@ -14,7 +14,8 @@ mkdir -p "${amici_build_dir}" cd "${amici_build_dir}" if [ "${GITHUB_ACTIONS:-}" = true ] || - [ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ]; then + [ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ] || + [ "${ENABLE_GCOV_COVERAGE:-}" = TRUE ]; then # Running on CI server build_type="Debug" # exceptions instead of terminate() diff --git a/scripts/installAmiciSource.sh b/scripts/installAmiciSource.sh index 514926773f..1c0a975708 100755 --- a/scripts/installAmiciSource.sh +++ b/scripts/installAmiciSource.sh @@ -33,7 +33,7 @@ fi export PYTHON_EXECUTABLE="${AMICI_PATH}/venv/bin/python" python -m pip install --upgrade pip wheel -python -m pip install --upgrade pip setuptools cmake_build_extension==0.5.1 numpy +python -m pip install --upgrade pip setuptools cmake_build_extension==0.6.0 numpy python -m pip install git+https://github.com/FFroehlich/pysb@fix_pattern_matching # pin to PR for SPM with compartments AMICI_BUILD_TEMP="${AMICI_PATH}/python/sdist/build/temp" \ python -m pip install --verbose -e "${AMICI_PATH}/python/sdist[petab,test,vis]" --no-build-isolation diff --git a/src/CMakeLists.template.cmake b/src/CMakeLists.template.cmake index ee50a551e8..dbad3e146c 100644 --- a/src/CMakeLists.template.cmake +++ b/src/CMakeLists.template.cmake @@ -38,6 +38,10 @@ endif() find_package(Amici TPL_AMICI_VERSION REQUIRED HINTS ${CMAKE_CURRENT_LIST_DIR}/../../build) message(STATUS "Found AMICI ${Amici_DIR}") +set_target_properties(Upstream::amici PROPERTIES + MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo;Release; + MAP_IMPORTED_CONFIG_RELEASE Release + MAP_IMPORTED_CONFIG_DEBUG Debug;RelWithDebInfo;) # Debug build? if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}") @@ -47,7 +51,6 @@ if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}") else() add_compile_options(-O0 -g) endif() - set(CMAKE_BUILD_TYPE "Debug") endif() # coverage options