On Mon, Jul 29, 2024 at 10:55 PM Daniel Sahlberg <daniel.l.sahlb...@gmail.com> wrote: > > Den sön 28 juli 2024 kl 20:00 skrev Stefan Sperling <s...@apache.org>: >> >> On Fri, Jul 26, 2024 at 10:41:14PM +0200, Daniel Sahlberg wrote: >> > I also tried OpenBSD but failed on missing Expat ("Could not find a package >> > configuration file provided by "expat" with any of the following names: >> > expatConfig.cmake expat-config.cmake [....]". I could not figure out if >> > this is a missing package in OpenBSD or that Expat on OpenBSD doesn't >> > provide the required cmake file. I hope @Stefan Sperling <s...@apache.org> >> > can chime in on this issue! >> >> The expat library is part of openbsd base + comp installation sets. >> Any default install will have it. >> >> There is a pkg-config file: /usr/lib/pkgconfig/expat.pc >> >> cmake needs to be installed with pkg_add, and a FindEXPAT.cmake module >> is part of the cmake package. Does this help? >> >> Contents of FindEXPAT.cmake listed below: > > > [cut] > > Thank you Stefan, that helped a lot. > > CMake is far from my comfort zone but I've tested the following change and it > seems to work on both OpenBSD and Ubuntu 24.04: > > [[[ > Index: CMakeLists.txt > =================================================================== > --- CMakeLists.txt (revision 1919555) > +++ CMakeLists.txt (working copy) > @@ -174,8 +174,8 @@ > > ### EXPAT > > -find_package(expat CONFIG REQUIRED) > -add_library(external-xml ALIAS expat::expat) > +find_package(EXPAT REQUIRED) > +add_library(external-xml ALIAS EXPAT::EXPAT) > > ### LZ4 > > @@ -481,7 +481,7 @@ > message(STATUS " Dependecies:") > message(STATUS " APR ........................... : ${APR_VERSION}") > message(STATUS " APR-Util ...................... : ${APRUTIL_VERSION}") > -message(STATUS " EXPAT ......................... : ${expat_VERSION}") > +message(STATUS " EXPAT ......................... : > ${EXPAT_VERSION_STRING}") > message(STATUS " ZLIB .......................... : ${ZLIB_VERSION}") > message(STATUS " LZ4 ........................... : ${lz4_VERSION}") > message(STATUS " UTF8PROC ...................... : ${UTF8PROC_VERSION}") > ]]] > > @Timofei, does this make sense? Notably, does it work on Windows? > > Kind regards, > Daniel >
Hi, Thank you! There are two different standard ways for finding dependencies in CMake; in Config mode or using modules. There is an explanation about them in the find_package documentation [1]. The advantage of using config is that it is generated during the build of the library, so it could handle the library configuration more correctly. Initially, I wanted to use config for finding all libraries, but most of the libraries just don't provide it, so I decided to use it only for the libraries which do (these libraries are Expat and LZ4). Also, see change from r1918954 where this behaviour has changed. The original problem is that the Expat config file wasn't generated correctly for that system or it is not included into a package (in the current case, I think that it is just excluded from the package). So, there are lots of problems with using Config mode; it is so challenging to generate a config file, the configs could be just excluded from the package that is used for build, and sometimes they might be unstable. The resolution that Daniel suggested seems to be nice, since we're migrating from configs. Additionally, if so, there could be a similar problem with LZ4, when SVN_USE_INTERNAL_LZ4 is disabled. If there is, we should also do something similar for external LZ4. Hope this explains well, because it is so complicated :) [1] https://cmake.org/cmake/help/latest/command/find_package.html -- Timofei Zhakov