Skip to content

Propagate CXXFLAGS correctly to setup.py #1188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

VincentRouvreau
Copy link
Contributor

When CXXFLAGS environment variable is set, with setuptools >= 74.0.0, python compilation flags are removed.
Take the ones coming from CFLAGS (as setuptools is doing before overwriting them with the CXXFLAGS environment variable value).
It also adds CMAKE_CXX_FLAGS_RELEASE | CMAKE_CXX_FLAGS_DEBUG to setup.py extra_compile_args in order to add '-O3' in release mode and speed up computation.

Could fix conda-forge/gudhi-feedstock#71 (to investigate)

@VincentRouvreau VincentRouvreau added the build The build system (CMake, etc) label Mar 14, 2025
Comment on lines +366 to +370
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(GUDHI_COMPILATION_FLAGS_STRING ${CMAKE_CXX_FLAGS_DEBUG})
else()
set(GUDHI_COMPILATION_FLAGS_STRING ${CMAKE_CXX_FLAGS_RELEASE})
endif()
Copy link
Member

Choose a reason for hiding this comment

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

I don't like hard-coding that there are only Debug and Release, there are more build types in CMake. Sadly, I think any clean way to handle it would require non-trivial changes (for instance delaying some operations from configuration to generation or even build, so we can use generator expressions). So I guess we could go with this temporarily 🙈

Comment on lines +371 to +372
# Compilation flags are in a string. Transform it to a list and append them to GUDHI_PYTHON_EXTRA_COMPILE_ARGS
string(REPLACE " " ";" GUDHI_COMPILATION_FLAGS_LIST ${GUDHI_COMPILATION_FLAGS_STRING})
Copy link
Member

Choose a reason for hiding this comment

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

I assume it breaks if the flags contain -I/some/dir with/a space/? It is probably already broken elsewhere in our build stuff though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build system (CMake, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build without optimization on macos arm64
2 participants