Cmake cannot find libaec

I installed package libaec. Cmake could not find the library.

$ pacman -Qo /usr/lib64/ 
/usr/lib/ is owned by libaec 1.0.6-1

$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION .3.25)
find_package(libaec REQUIRED)

$  cmake ..
CMake Error at CMakeLists.txt:5 (find_package):
  By not providing "Findlibaec.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "libaec", but
  CMake did not find one.

  Could not find a package configuration file provided by "libaec" with any
  of the following names:


  Add the installation prefix of "libaec" to CMAKE_PREFIX_PATH or set
  "libaec_DIR" to a directory containing one of the above files.  If "libaec"
  provides a separate development package or SDK, be sure it has been

My fix that appears to work is:

# pwd
# mkdir libaec
# mv libaec-config* libaec

Also, pkg-config is not aware of libaec. It looks to me as an issue with the libaec package configuration.

Why? What are you building with CMake? If we don’t know, we can’t help you.

Whatever project it is, the developer may need to make an adjustment. It would be better to create an upstream issue to let the developer know.

libaec does not have a pkg-config file, see the file list.

That’s not a fix. Don’t modify system files.

I am preparing software that uses meson to build it. Meson finds dependencies with pkg-config, with a fallback to Cmake. My software requires libaec. The software will be running on RedHat, which has different packaging system.
I did some further research. On manjaro CMake works, but meson still complains. On RH8, neither pkg-config or CMake can find the library.

Link to the code? Logs?

I think I got it now. Code does not matter, (the old source built with make, is here GitHub - yt87/libwgrib2: Shared library based on wgrib2 executable to read/write GRIB2 files), it is meson configuration:


The file ` is:

project('foo', 'c', version: '0.0.0')
dependency('libaec', modules: ['libaec::aec'], required: true)

I had to add the modules key to get it work. Without it, the output was:

$  meson setup --wipe foo 
The Meson build system
Version: 1.0.0
Source dir: /mnt/sdb1/projects/work
Build dir: /mnt/sdb1/projects/work/foo
Build type: native build
Project name: foo
Project version: 0.0.0
C compiler for the host machine: cc (gcc 12.2.1 "cc (GCC) 12.2.1 20230111")
C linker for the host machine: cc ld.bfd 2.40
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.8.0)
Found CMake: /usr/bin/cmake (3.25.2)
WARNING: Could not find and exact match for the CMake dependency libaec.

However, Meson found the following partial matches:

    ['libaec::aec', 'libaec::sz']

Using imported is recommended, since this approach is less error prone
and better supported by Meson. Consider explicitly specifying one of
these in the dependency call with:

    dependency('libaec', modules: ['libaec::<name>', ...])

Meson will now continue to use the old-style libaec_LIBRARIES CMake
variables to extract the dependency information since no explicit
target is currently specified.

Run-time dependency libaec found: NO (tried pkgconfig) ERROR: Dependency "libaec" not found, tried pkgconfig

A full log can be found at /mnt/sdb1/projects/work/foo/meson-logs/meson-log.txt

This requires the directory libaec present in '/var/lib/cmake, not the two files as listed in the package. Note that libaec is an oddity, the content of the cmake directory are directories (with few exceptions).