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

fix compile_definitions with no value #15545

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conan/tools/cmake/toolchain/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ class CMakeToolchain(object):

# Preprocessor definitions
{% for it, value in preprocessor_definitions.items() %}
{% if value is none %}
add_compile_definitions("{{ it }}")
{% else %}
add_compile_definitions("{{ it }}={{ value }}")
{% endif %}
{% endfor %}
# Preprocessor definitions per configuration
{{ iterate_configs(preprocessor_definitions_config, action='add_compile_definitions') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def generate(self):
tc.preprocessor_definitions["spaces2"] = "me you"
tc.preprocessor_definitions["foobar2"] = "bazbuz"
tc.preprocessor_definitions["answer2"] = 42
tc.preprocessor_definitions["NOVALUE_DEF"] = None
tc.preprocessor_definitions.release["escape_release"] = "release partially \"escaped\""
tc.preprocessor_definitions.release["spaces_release"] = "release me you"
tc.preprocessor_definitions.release["foobar_release"] = "release bazbuz"
Expand Down Expand Up @@ -382,6 +383,9 @@ def build(self):
SHOW_DEFINE(foobar_debug);
SHOW_DEFINE(answer_debug);
#endif
#ifdef NOVALUE_DEF
printf("NO VALUE!!!!");
#endif
return 0;
}
""")
Expand Down Expand Up @@ -411,6 +415,7 @@ def build(self):
assert 'spaces_release=release me you' in client.out
assert 'foobar_release=release bazbuz' in client.out
assert 'answer_release=42' in client.out
assert "NO VALUE!!!!" in client.out

client.run("install . -pr=./profile -s build_type=Debug")
client.run("build . -pr=./profile -s build_type=Debug")
Expand Down