diff --git a/CMakeLists.txt b/CMakeLists.txt index c3525ba..6e10a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,24 @@ python3_add_library(_sparsediffengine MODULE sparsediffpy/_bindings/bindings.c ) +# Match the engine's per-config optimization flags so the extension doesn't rely on +# the toolchain's default CMAKE_C_FLAGS_RELEASE. +if(MSVC) + target_compile_options(_sparsediffengine PRIVATE + $<$:/Od /Zi> + $<$:/O2 /DNDEBUG> + $<$:/O2 /Zi /DNDEBUG> + $<$:/Os /DNDEBUG> + ) +else() + target_compile_options(_sparsediffengine PRIVATE + $<$:-g -O0> + $<$:-O3 -DNDEBUG> + $<$:-O2 -g -DNDEBUG> + $<$:-Os -DNDEBUG> + ) +endif() + target_include_directories(_sparsediffengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include ${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include/atoms diff --git a/pyproject.toml b/pyproject.toml index 02ae584..677defb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ content-type = "text/markdown" [tool.scikit-build] cmake.version = ">=3.15" +cmake.build-type = "Release" wheel.packages = ["sparsediffpy"] # Persistent build dir: avoids scikit-build-core's TemporaryDirectory, whose cleanup # intermittently fails on Windows CI with WinError 32 (lingering mspdbsrv/AV handle).