[question] How to generate no configuration suffix when using CMakeDeps?
See original GitHub issueWhen consuming targets and CMake variables generated by CMakeDeps, it generates all variables with a suffix based on its configuration:
@property
def suffix(self):
if not self.conanfile.is_build_context:
return ""
return self.cmakedeps.build_context_suffix.get(self.conanfile.ref.name, "")
As result, it regenerates variables like FOO_LIBS_RELEASE
and foo_COMPILE_DEFINITIONS_RELEASE
.
The question is, how to generate only FOO_LIBS
(without build type suffix)?
We could try a workaround, forcing the CMakeDeps
configuration, but fails:
def generate(self):
deps = CMakeDeps(self)
deps.configuration = ""
deps.generate()
conan create . foo/0.1@
ERROR: Traceback (most recent call last):
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conans/errors.py", line 34, in conanfile_exception_formatter
yield
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conans/client/generators/__init__.py", line 253, in write_toolchain
conanfile.generate()
File "/Users/uilian/.conan/data/foo/0.1/_/_/export/conanfile.py", line 16, in generate
tc.generate()
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conan/tools/cmake/cmakedeps/cmakedeps.py", line 46, in generate
generator_files = self.content
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conan/tools/cmake/cmakedeps/cmakedeps.py", line 88, in content
self._generate_files(require, dep, ret, find_module_mode=False)
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conan/tools/cmake/cmakedeps/cmakedeps.py", line 101, in _generate_files
ret[data_target.filename] = data_target.render()
File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conan/tools/cmake/cmakedeps/templates/target_data.py", line 20, in filename
data_fname += "{}-{}".format(self.file_name, self.configuration.lower())
AttributeError: 'NoneType' object has no attribute 'lower'
Some projects use LIBS
instead of LIBRARIES
and have been working so far, and forcing to patch only because Conan uses target multi feature sounds a bit aggressive.
/cc @ericLemanissier
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
[question] CMakeDeps and layout() creates but wrong test ...
I would need to see the imports. This is not necessary anymore with the new from conan.tools.cmake import CMake : def _configure_cmake(self): ...
Read more >CMakeDeps — conan 1.56.0 documentation
The CMakeDeps helper will generate one xxxx-config.cmake file per dependency, ... You can use the build_context_suffix attribute to specify a suffix for a ......
Read more >Cmake find_package does not work with Doxygen
I am trying to have CMake find Doxygen on a bunch of different systems and configurations: Online documentation is generated on Ubuntu; Local ......
Read more >conan Changelog - pyup.io
Bugfix: The `CMakeDeps` generator was not working properly when the consumer maps configurations of the dependencies using `CMAKE_MAP_IMPORTED_CONFIG_XXX`.
Read more >CMake 3.25.1 Documentation
When using one of the IDE Build Tool Generators, no particular environment is needed. Generate a Project Buildsystem¶. Run CMake with one of...
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 FreeTop 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
Top GitHub Comments
Thanks for the report. cf https://github.com/conan-io/conan-center-index/pull/13228 for an example of actual failure caused by this issue
re-ping @jcar87 do you need more information ?