Spencer Russell
2018-08-31 06:11:29 UTC
I'm working on a cross-compile environment to build portaudio binaries for a bunch of platforms. I'm starting with the linux builds, so I first build ALSA and JACK and install them to `$prefix/lib`. When I try to run cmake it's able to find ALSA but not JACK.
I'm running cmake with the `-DCMAKE_INSTALL_PREFIX=$prefix` option. Cmake is able to successfully find ALSA using the built-in FindALSA module, which uses `find_library` internally. `ALSA_LIBRARIES` is set to the full path of my `libasound.so` library. The FindJACK module that comes with the portaudio source tarball however uses `pkg_search_module`, which sets `JACK_LIBRARIES` to just `jack`.
If I remove the pkgconfig lines and let it fall back to `find_library` then everything works fine. Probably in most cases the pkgconfig approach works fine because the linker can just take the `-ljack` and find it in the standard system library path, but it causes problems when cross-compiling or any time your libraries are in a non-standard location.
Alternatively running cmake with the option `-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON` disables pkgconfig, and also works.
Just wanted to report this in case the devs want to tweak the build system, or at least provide my solution to future generations of cross-compilers...
I'm running cmake with the `-DCMAKE_INSTALL_PREFIX=$prefix` option. Cmake is able to successfully find ALSA using the built-in FindALSA module, which uses `find_library` internally. `ALSA_LIBRARIES` is set to the full path of my `libasound.so` library. The FindJACK module that comes with the portaudio source tarball however uses `pkg_search_module`, which sets `JACK_LIBRARIES` to just `jack`.
If I remove the pkgconfig lines and let it fall back to `find_library` then everything works fine. Probably in most cases the pkgconfig approach works fine because the linker can just take the `-ljack` and find it in the standard system library path, but it causes problems when cross-compiling or any time your libraries are in a non-standard location.
Alternatively running cmake with the option `-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON` disables pkgconfig, and also works.
Just wanted to report this in case the devs want to tweak the build system, or at least provide my solution to future generations of cross-compilers...