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
allow integers as CMakeToolchain.preprocessor_definitions #8645
Merged
memsharded
merged 5 commits into
conan-io:develop
from
memsharded:feature/toolchain_cmake_preprocesor_int
Mar 21, 2021
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6fbc4fe
allow integers as CMakeToolchain.preprocessor_definitions
memsharded c7203ac
fix test
memsharded e9163a7
fix test
memsharded 86c5077
ordered dicts
memsharded 416b07f
Merge branch 'develop' into feature/toolchain_cmake_preprocesor_int
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this? I though you planned to remove that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not yet fully decided, on one hand it is clear there is demand, on the other, it could be a pure build-system thing, and Conan agnostic about it. In the meantime, it totally makes sense that users want to provide integer preprocessor definitions, as they are very common. Maybe @guiserle could elaborate a bit further about their use case, and why such preprocessor definitions are not integrated in the build system scripts directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks a lot for considering my request.
My use case is to define configuration values for libraries such as FreeRTOS or MCU SDK packages. Currently we define conan options for such values and pass those values to cmake on conan
build()
method. However that means for every configuration value (and these libraries have lots of them) we need to add logic on both conanfile.py and cmake files.On top of that we are using Clion as IDE and we need to add these cmake variables (and others such as version numbers) on the IDE project settings manually. I was thinking about setting these values directly on
generate()
method so they would all be included in toolchain file and it would only be necessary to add the toolchain as value for CMAKE_TOOLCHAIN_FILE.If that is not the intended use case for the generate method and this should be implemented on another way, I will understand it. Also I have considered the implementation of a custom generator for my particular use case if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to merge this, seems a valid use case, thanks for the feedback.
Just beware that
self.options
are also always strings, even if you defined them asoption: [1, 2, 3]
, internally, they are always strings. So you might need to convert it to ints, if you use it from there likecmake.preprocessor_defintions["MYDEF"] = int(self.options.myoption)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great. Thanks for taking my use case into account!