vyasr commented on issue #36411: URL: https://github.com/apache/arrow/issues/36411#issuecomment-2738185657
> > I think that this question means whether `meson install` can install `XXXConfig.cmake` or not (downstream projects can find a project by `find_package(XXX)` or not). I think that this question doesn't mean `ExternalProject` nor `FetchContent`. > > Meson has a feature that generates `XXXConfig.cmake`: https://mesonbuild.com/CMake-module.html#cmakeconfigure_package_config_file > > But it didn't work well when I tried it for Apache Arrow GLib. (It may work well now.) > > From memory, cmake "needs" multiple files here, depending on how you set things up: > > * FindXXX.cmake -- standalone, handwritten lookups > > * XXXConfig.cmake paired with XXXTargets.cmake, the former is equivalent to the `Version:` field of a pkg-config file while the latter is equivalent to the `Libs:` and `Cflags:` fields > > > cmake comes with a template for the former and meson can help you install that. Generating the latter is apparently incredibly complex as no template exists, not even for simple cases, though I suspect the majority of the cmake complexity could be simplified to "discover the library by pinning the install `libdir` location in the generated file, using find_library() to detect the library in that location, and setting it as the interface property". > > I'm not averse to adding this, although it should also be possible to write a simple one by hand. I suspect, but am not sure, that the person who added support to meson for generating `XXXConfig.cmake`, figured that everyone would want to handwrite the Targets file anyway. As @eli-schwartz said, a CMake config file is typically generated using a `config.cmake.in` template and the [`configure_package_config_file`](https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html) helper function. In principle, the config file could be all you need if you hand wrote the entire thing. In practice, you want the generation of CMake targets that occurs when someone else does a `find_package(my_pkg)` to be automatic, so the config file template will `include` the corresponding targets file. The targets file is usually generated by the `install` command (specifically [the `install(EXPORT)` signature](https://cmake.org/cmake/help/latest/command/install.html#export)). You do not need a template for that one. The typical usage is to run `install(TARGETS ... EXPORT pkg-exports)` during the build so that `pkg-exports` becomes a collection of all the targets that you want to export, then you run `install(EXPORT pkg-exports FILE path/to/pkg-targets.cmake)` to produce the targets file in your install tree. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org