Skip to content

build: Generate better pkg-config file for SYSROOT builds (part 2)

James Le Cuirot requested to merge chewi/libxml2:cmake-pkg-config into master

Here's a follow up to !222 (merged) that also mostly addresses !221 (closed), as long as you have pkg-config files installed for the dependencies.


autoconf: Don't bake build time CFLAGS into pkg-config file

Having slept on it, I've realised that baking the dependency CFLAGS into the pkg-config file is pointless when it is only used to link against them. It may even cause problems.


autoconf: Include non-pkg-config dependency flags in the pkg-config file

These were present before, but I accidentally dropped them in my recent build improvements.


cmake: Generate better pkg-config file for SYSROOT builds under CMake

I recently fixed this for Autotools but said that fixing this for CMake was not feasible due to it using find_package rather than pkg_check_modules. I then thought about it and couldn't find any reason why CMake couldn't try pkg_check_modules first and then fall back to find_package, as that's basically what Autotools does.

I had wanted to use the linker flags generated by CMake when it does fall back to find_package, but it only returns direct paths to the libraries, as opposed to -l flags. Baking these library paths into the pkg-config and xml2-config files would break static linking and cross-compiling, so I've stuck with the -l flags we already have.

There is no need to set CMAKE_REQUIRED_LIBRARIES because we already add the dependencies to the library target.

Merge request reports

Loading