One of the canonical ways to include libraries that do not give support for CMake is to fallback to pkg-config
.
For example the FFTW library can be found in this way:
find_package(PkgConfig)
pkg_search_module(FFTW REQUIRED fftw3 IMPORTED_TARGET)
and made available by
include_directories(PkgConfig::FFTW)
link_libraries(PkgConfig::FFTW)
However, in some configurations, pkg-config
does not return an include path (I guess because if the library headers are in a system path, it is not needed to add an -I
option).
The problem is that in such a case, CMake attaches the option -IPkgConfig::FFTW
which is an incorrect path.
In fact the compiler (in my case g++
) complains, and, with certain warning levels, produces an error.
How can I prevent CMake or the pkg-config CMake package from generating these bad include paths?