[feature] Binary Conan options should be expressed as an `option()` in CMake when generated with CMakeToolchain
See original GitHub issueThis is common to have True/False options in conanfile.py. For example:
options = {
"build_docs": [True, False]
}
the above is translated by the CMakeToolchain to
set(UNITS_BUILD_DOCS "True" CACHE STRING "Variable UNITS_BUILD_DOCS conan-toolchain defined")
This is seen in a GUI as:

However, it would be nicer if those would be generated either as:
set(UNITS_BUILD_DOCS "True" CACHE BOOL "Variable UNITS_BUILD_DOCS conan-toolchain defined")
or
option(UNITS_BUILD_DOCS "Variable UNITS_BUILD_DOCS conan-toolchain defined" ON)
The new behavior better states the purpose of the option and also improves CMake cache variable presentation in GUIs:

- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
CMakeToolchain — conan 1.28.2 documentation
The CMakeToolchain will generate 2 files, after a conan install command (or before calling the build() method when the package is being built...
Read more >FindProtobuf — CMake 3.25.1 Documentation
Locate and configure the Google Protocol Buffers library. New in version 3.6: Support for find_package() version checks. Changed in version 3.6: All input...
Read more >Cmake Conan - Github Mirror - GitLab - AIMMS
conan_cmake_autodetect(). This function will return the auto-detected settings (things like build_type, compiler or system name) so you can pass ...
Read more >Frequently Asked Questions - vcpkg - Read the Docs
Can vcpkg create pre-built binary packages? What is the binary ... Can I use my own CMake toolchain file with vcpkg's toolchain file?...
Read more >Conan Package Manager in Practice - GitHub Pages
can re-run above command from new shell if disconnected ... CMakeToolchain(self).generate() # -> conantoolchain.cmake (variables translated from conan ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Now I get it, thanks!
What I see is that by the moment you define the
tc.variables, the option value is already a string, not a value. All Conan options and settings are converted to strings. So it is not possible to deduce it from the option value, it would require a explicit cast in user code likethis is basically equal to https://github.com/conan-io/conan/issues/8632, but for variables and not preprocessor_definitions
But you are right, probably it should be a property of
tc.variables.