-
Notifications
You must be signed in to change notification settings - Fork 981
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_generator[multi]: add more "alias" variables #7691
Comments
Hi, @SpaceIm IMHO, we should limit Conan features to the common functionality shared by different build-systems, something that every one of them can take advantage of: names, filenames,... although some of them are already too CMake-centric (but it is ok, CMake is one of the biggest players if not the biggest one). Following this reasoning, I think that For CMake, we are including the Of course, I'm open to other alternatives, but if we agree on this and the solution is as easy as moving the inclusion of the wdyt? Do you really think we need more attributes in the Thanks for your feedback I know there is a big disadvantage: anything in the |
My request was not very clear maybe. So for example with Official CMake module file: https://cmake.org/cmake/help/v3.18/module/FindJasper.html
jasper conan recipe: Content of def package_info(self):
self.cpp_info.names["cmake_find_package"] = "Jasper"
self.cpp_info.names["cmake_find_package_multi"] = "Jasper"
self.cpp_info.names["pkg_config"] = "jasper"
self.cpp_info.libs = ["jasper"]
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("m") Generated module file (just a subpart), if using set(Jasper_INCLUDE_DIRS "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(Jasper_INCLUDE_DIR "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(Jasper_INCLUDES "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include") I would like that conan generator adds more variables commonly found in official module files: set(Jasper_INCLUDE_DIRS "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(JASPER_INCLUDE_DIRS "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(Jasper_INCLUDE_DIR "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(JASPER_INCLUDE_DIR "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(Jasper_INCLUDES "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include")
set(JASPER_INCLUDES "C:/Users/spaceim/.conan/data/jasper/2.0.19/_/_/package/5b4f006245c66309d6bcbdbb4fe6daef48420dbc/include") Here I would like to also have:
Uppercase variables are common in official CMake module files (but for exemple https://cmake.org/cmake/help/v3.18/module/FindPostgreSQL.html or https://cmake.org/cmake/help/v3.18/module/FindXercesC.html are exceptions). For version you will equally find these variants: If conan made the decision in the first place to create |
There is also the As a C++ developer, I would love to see some standardization in all these naming, but I know the world is different. If I were to vote, I would say that Conan should provide the standard variables and any other variable should be provided by the recipe via I would really want to know what other people think about it. Maybe we should post this question in the |
I can open a discussion in conan-center-index, but I strongly believe that the new variables proposed in this PR are standard variables. There are a lot of recipes in CCI for which we have to patch a valid upstream CMakeLists because those variables are missing, or worse sometimes it silently fails in upstream CMakeLists at some point just because |
👍 Let's gather some attention on this issue, and see what others think about it. |
I agree with @SpaceIm, there is a ton of inconsistency in the CMake ecosystem about whether to use That said, I do agree with @jgsogo that cpp_info should be more or less done (mainly excluding #6125 and #7240), and that pretty much all other CMake specific stuff should go into build modules. |
My personal opinion: I really hate how CMake is that much inconsistent, and still the community pushes Conan to conform to such bad practices instead of pushing CMake or accepting having to do some simple modifications in the consumer scripts. If Conan introduces all the different casing for If I understand it correctly, this would only apply when the variables are used instead of using the generated targets with is actually the recommended approach, isn't it? Shouldn't we be pushing towards the usage of targets as much as possible? Are there strong reasons to not use the targets? If we decided not to automatically generate those variables, how many packages in conan center would require custom build_modules to add those variables? |
The problem is one of scale, we aren't really talking about 10s of packages, more like hundreds or thousands, so in my opinion Conan's goal should be first and foremost compatibility (not just for CMake, but also with pkg-config, qmake, meson, etc). I agree that there are a bunch of bad practices with CMake, but that is true for any heavily used piece of software -- I personally have to deal with 20+ year-old C++ code on a daily basis, so I certainly sympathize with pain of dealing with compatibility. To answer your question, yes, using the generated targets is the recommended approach, but there are plenty of packages that don't use them, especially when it comes to older packages (both as consumers and producers). The example of Jasper in particular is a case where the official script does not provide any CMake target, so the entire CMake ecosystem uses variables when consuming Jasper. As for what conan center packages would require the variables, at the very least it would include everything shipped with CMake (https://cmake.org/cmake/help/v3.18/manual/cmake-modules.7.html#find-modules). Some of these provide CMake targets, but many don't and only provide variables. My guess is that there wouldn't be many more packages outside of this list that really need the variables. |
I'll include my grain of salt to this issue. Also FindProtobuf.cmake defines at least one variable ( I would like to see a way for conan recipes to specify custom variables for the |
Built-in CMake modules don't always provide imported targets, and if they do it requires sometimes recent CMake versions that projects can't use as a minimum version:
I guess with conan 1.33.0, we may add custom CMake module files to properly set additional variables for |
Here is an attempt to provide official variables in openssl recipe: conan-io/conan-center-index#4597 |
List if libraries, which might be also affected: |
This issue was reporting the legacy CMake integration, which has been superseded by the new one in Conan 1.X https://docs.conan.io/1/reference/conanfile/tools.html, and removed in Conan 2.0: https://docs.conan.io/2/reference/tools/cmake.html. Closing this ticket as outdated. Please update to use the modern CMake integration, and please don't hesitate to open new tickets as necessary. Thanks! |
Some official CMake module files have uppercase variables (most of them actually), even if filename or namespace is not uppercase, but
cmake_find_generator
andcmake_find_generator_multi
generate variables likeOpenSSL_INCLUDE_DIRS
.So let's look at official FindOpenSSL module file: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
Current openssl CCI recipe will generate
FindOpenSSL.cmake
file if consumer usescmake_find_generator
generator, which is fine.But generated variables are
OpenSSL_FOUND
,OpenSSL_INCLUDE_DIR
,OpenSSL_INCLUDE_DIRS
,OpenSSL_LIBRARIES
etc. Unfortunately, in official CMake module file, all these variables are fully uppercase, and CMake variables are case sensitive.Also sometimes there is a variable like
OPENSSL_LIBRARY
(not in OpenSSL official CMake module, it's just an example), orJASPER_VERSION_STRING
instead ofJASPER_VERSION
.It would be nice to add those variables in generated module and config files:
${names or filenames}_LIBRARY
(clone of${names or filenames}_LIBRARIES
).${names or filenames}_VERSION_STRING
(clone of${names or filenames}_VERSION
).Some recipes are hard to properly package with
cmake_find_package
, without introducing tedious patches applying non official CMake variables names. Yes, because some official CMake modules files don't define targets, even in CMake 3.18, so the proper and transparent way to consume these libraries is to use those variables...The text was updated successfully, but these errors were encountered: