-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[feature] cmake_find_package[_multi] generators: provide a way to create non namespaced imported targets #7615
Comments
Hi @SpaceIm First, it is sad to discover this CMake lack of consistency (though not very surprising). Regarding the multiple module/config definitions, I am not so sure. I would say that this seems too much, and Conan should provide only one of them (I guess the modern module one). |
@SpaceIm do you have an idea how the syntax to describe non-namespaced targets may look like? e.g. assigning an empty string, or |
@SSE4 I don't know how it could be implemented with existing cpp_info properties without breaking current behaviour. For example, setting |
Having multiple namespaces would also be useful. In general, the cmake_find_package generators should assume that everything can be modified. |
Difference between component name and underlying imported target can be emulated, but not multiple namespace (openexr also has multiple namespaces). |
Agreeing with these points, confusingly CMake target names can be ANYTHING (and with my relatively brief CMake experience I've seen almost every type of target name in active use). Some packages like GTest even define things like GTest::GTest and then GTest::Main which as far as I know cannot be modeled with components right now. |
* add args/0.12.1 * Change the recipe to mzdun-args - Fix test_package issues - Rework _working_compilers and hand-crafted Version to _compilers_minimum_version, tools.Version and tools.check_min_cppstd - Use cached CMake instance - Bump library version to one compiling under apple-clang * Fix last ON/OFF to True/False * Remove unused code - Delete fPIC, when building .so - Limit apple-clang to 10.0 (see [1] for optional, string_view and Elementary string conversions) [1] https://en.cppreference.com/w/cpp/compiler_support/17#C.2B.2B17_library_features * Fix save on (Deleted) after git mv * Ban DLLs with MT/MTd and clang 7 with libc++ * Get compilation fixes for the library * Provide CMake wrapper * Add support for cmake_find_package[_multi] * Add FIXME warning about conan-io/conan#7615
unfortunately, I don't see how it could be implemented with the current
|
I have created this PR #8130 to try a new approach using build modules for this kind of thing. I feel that CMake has so many different moving parts that it is a bit messy to keep adding things to the cpp_info model. WDYT? |
@danimtb, looking at the PR, I don't really understand how a robust recipe could be written, ie providing non namespaced targets for ===================== if(NOT target AND namespace::target)
add_library(target INTERFACE IMPORTED)
target_link_libraries(target INTERFACE namespace::target)
endif() ===================== It seems also to require lot of boilerplate code. |
Thanks for working on this, this is a very important feature! Just a reminder: Now it's good cmake practice to use |
I'll write an example with a POC (it was closed with the PR) |
Currently,
cmake_find_package
andcmake_find_package_multi
generators always create namespaced imported targets in generated module/config files.While not considered as best practice, it's not uncommon that official CMake config file of a library create non-namespaced imported targets (and quite uncommon for module files because official ones are usually provided by Kitware).
This is a non-exhaustive list of CCI recipes whose official config file creates non-namespaced targets, to show you that it's not just a corner case:
It's worth noting that a library may have an official module and config file, and one might create namespaced targets but not the other.
libpng and freetype are good examples.
The text was updated successfully, but these errors were encountered: