-
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 generator: custom target #6069
Comments
I'll tag this as a look into, we need to think if we are requesting this as a useful feature, or it is just something we need for protobuf/protoc because of the way we have created these recipes. |
My opinion about all this stuff related to protoc/protobuf: I really feel like that the components approach (#5408) is the way to go. Probably all the protobuf libraries should be in the same package (it is the way it is designed) and we would get (with the components feature) targets Together, the new cross-building model and the components should be enough to target this problem without adding a new feature to rename targets (or rename the namespace for the targets). Nevertheless, in the generic scenario of cross-compilation (native is just a particular use-case), I'm not sure if we would be able to use |
It's a trade off, we can put all together, but we can't invoke cmake macro when cross-building. I know there are people interested in this scenario, even I used Protobuf for embedded stuff in the past. Protobuf is not only one, gRPC is on the same boat. |
As for the special case of Protobuf and cross compiling: I think for many people, it would be a nogo / step backward to do the proto file compilation before If you are cross-compiling, usually you would install the package for both build and target architecture. You would then pass a During the CMake execution it is also asserted that At least this works with the For our own packages that come with a "compiler" such as protoc, we create a pattern such as this
What this means is, when you do a find_package, the targets are always included. The targets for the compiler are only included when not cross compiling. When cross compiling an imported target is created instead. |
Another related case: conan-io/conan-center-index#405 The CMake file has a name, but the target name in the cmake module is not the same. |
packaging RocksDB has the same issue: Currently using |
@jgsogo Plus adding a variable that contains the run command would also be nice. set(CONAN_protobuf_RUN_COMMAND "${CMAKE_COMMAND}" -E env "DYLD_LIBRARY_PATH=${Protobuf_LIB_DIRS}:${CONAN_LIB_DIRS}" "${CONAN_protobuf_NAME}") for macos and something similar for the cmake_find_package(_multi) generator (and other os'es). Ideally, the interface for This is also interesting for python: see https://cmake.org/cmake/help/git-stage/module/FindPython.html There is currently no way to model |
I think if it is possible to support this in Conan it should be done, for the simple reason that it's currently possible in pure CMake to make the argument to For example, consider vcpkg's Could this be supported by adding a new property to |
Some comments in this issue are related to the components feature which has already been released. Using class Recipe:
name = "any-name"
def package_info(self):
self.cpp_info.names["cmake_find_package"] = "Boost"
self.cpp_info.components["not-exactly-coroutine"].names["cmake_find_package"] = "coroutine" This will generate target Am I missing something? IMO, this issue can be closed after all the effort (and more to come) related to components @madebr I cannot see how this is related to the first part of your comment about |
@jgsogo |
But, do you think this is something to add in the |
I can only think of cmake as its consumer + using it in the dependency graph alongside library components. I think the build_module should be able to use the conan generated variables and targets. Also, on MSVC, executables can have different suffixes for different build types (same for libraries). I just think all types of targets (that are installed in general) should be addable to the dependency graph. |
Now I see, it is tightly related to #7240 |
This will work fine for 1 package and produce For example, suppose in the future Boost is finally modularized in a way that gains mass acceptance. There may exist a Conan package for Boost-coroutine and another one for Boost-asio. From CMake these would be used by calling The solution you outline does not work if |
I see what you mean. Your example is valid, also |
@uilianries anything else need regarding filenames after having #7254 implemented? |
@danimtb No, we are good to go. |
Hi!
After the feature #5598, which helped a lot with
cmake_find_package
, now we have another cmake situation which can be solved with a new feature.I'll try to illustrate using a real case, Protobuf. This package was divided in two, the library (libprotobuf, libprotoc, libprotobuf-lite) and the compiler (.proto parser). The parser can be invoked from Cmake, using macros to generate both headers and sources:
Using
cmake_find_package
, Conan will provide Findprotoc.cmake, which has the CMake targetprotoc::protoc
, and forcmake
generator we will haveCONAN_PKG::protoc
from conanbuildinfo.cmake.However, those macros are looking for the original target,
protobuf::protoc
. We could patch those cmake files, but this problem also could be avoided using a custom target:Now the
cmake_find_package
can use this new custom target name and all cmake files imported from protobuf will work straightforward.The current PR #5408 is adding new feature to
self.cpp_info
. Similar to this feature request.The text was updated successfully, but these errors were encountered: