-
Notifications
You must be signed in to change notification settings - Fork 993
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
[bug] tools.build:defines
is broken in multiconfig setting
#15921
Comments
I'm working on a PR |
Thanks for the report and the offer to fix it @stevenwdv This was tested in |
No it's the generator expressions, but I'll explain more in the PR and probably create a follow-up issue. Btw all contributing docs mention the |
#15922 will fix that, thanks for raising it too! |
The PR in #15924 will be released in 2.2.2 today, as it could be considered a regression. Thanks again for reporting. |
Maybe you can re-open this for now? |
Sure re-opening. It would be great to have a PR with a test similar to |
@memsharded What I don't understand yet is why the current test is passing (see #15924 (comment)) |
This is still broken in Conan 2.5. But the fix is quite simple, as I already commented in #15924 (comment): --- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -724,7 +724,7 @@ class ExtraFlagsBlock(Block):
{% if defines %}
{% if config %}
{% for define in defines %}
- add_compile_definitions($<$<CONFIG:{{config}}>:"{{ define }}">)
+ add_compile_definitions("$<$<CONFIG:{{config}}>:{{ define }}>")
{% endfor %}
{% else %}
add_compile_definitions({% for define in defines %} "{{ define }}"{% endfor %}) |
To consider these changes, we would need first a failing test that reproduces the issues. I am trying to reproduce, and added Maybe you want to try to do a change or a new test like
|
I have created a fix and test for this issue in PR #16637. |
…CMake (#15921) (#16637) * Add test for handling of tools.build:defines for Ninja multi-config CMake * Fix handling of tools.build:defines for (Ninja) multi-config CMake The CMake generator-expressions that results from the values given to Conan's `tools.build:defines` configuration will now properly be put into quotes to form a CMake string. (Note: CMake's generator-expressions should never contain any (non-escaped) quotes.) * use CMake 3.23 in test * fix Windows (might pass by luck, using clang++ instead of cl) * fix Windows activating conanbuild.bat for vcvars --------- Co-authored-by: memsharded <james@conan.io>
Describe the bug
tools.build:defines
is broken in multiconfig setting, e.g. with MSVC. The quoting in the generator expression is not correct inblocks.py
.How to reproduce it
tools.build:defines=['A=1', 'B=2']
EDIT: See PR #15924 for more info
The text was updated successfully, but these errors were encountered: