Skip to content
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

The CMAKE_ARGS environment variable doesn't allow to pass values with spaces #20

Open
yurivict opened this issue May 3, 2024 · 3 comments

Comments

@yurivict
Copy link

yurivict commented May 3, 2024

here

CXXFLAGS typically have spaces in them, so they can't be passed using the existing CMAKE_ARGS mechanism.

One possible solution is to re-define this variable to pass the Python list string, instead of a space-separated values.

@yurivict yurivict changed the title The CMAKE_ARGS environment argument doesn't allow to pass values with spaces The CMAKE_ARGS environment variable doesn't allow to pass values with spaces May 3, 2024
@fakufaku
Copy link
Collaborator

fakufaku commented May 7, 2024

Hi @yurivict , can you please give an example of a CXXFLAGS with spaces and how it failed?

Since everything ends up in a list passed to subprocess.run (here), I am no completely convinced this is an issue. But I may be wrong.

@yurivict
Copy link
Author

yurivict commented May 7, 2024

CXXFLAGS generally has spaces, for example CXXFLAGS="-O3 -std=c++20"

When CXXFLAGS is embedded in CMAKE_ARGS - CMAKE_ARGS can't be split using the space character, without regard for quotes.

I ended up using cmake directly and not through CMAKE_ARGS, but this splitting operation is an obvious bug.

@fakufaku
Copy link
Collaborator

fakufaku commented May 8, 2024

I see.

According to cmake doc, the inital value for CXXFLAGS is taken from the calling environment, you could define it before calling the setup.py routine.

CXXFLAGS="-O3 -std=c++20" python ./setup.py install

Another solution would be to use shlex.split instead of split in setup.py (ref), but it seems to remove the double quote around the CXXFLAGS value, so I am not sure how this would affect subprocess.run.

In  > shlex.split(cmake_args)
Out > ['CXXFLAGS=-O3 -std=c++20']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants