pkg-config includedir and source code includes do not match
Summary
If the codec2 library is not installed in the default library/include path, other projects cannot properly include it via pkg-config. E.g. I get include errors in my application on MacOS when having codec2 installed via brew.
- using #include <config2/config2.h leads to an error, the file cannot be found.
- using #include <config2.h> leads to an error inside config2.h: it cannot find <config2/version.h>
the pkg-config file defines the include path as
includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/codec2
But config2.h itself refers to other files using the codec2/XY.h.
This mismatch does not cause a problem on most Linux distress, as the lib will be installed inside the default include dir (/usr/include), so together with pkg-config, codec2.h and codec2/codec2.h and codec2/version.h are in the include path
Steps to reproduce Install codec2 in a non-default path. E.g. $HOME/. Try to compile this application.
#include <codec2/codec2.h>
int main() {
return 0;
}
Proposed fix
-
in codec2.pc, includedir could be set to
@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@. Then, all applications must includecodec2/codec2.h. This would be a breaking change to the existing include behaviour, some applications currently could includecodec2.h -
We could add both paths to the include dir: Cflags: -I${includedir}:${includedir}/codec2. This keeps the existing include behaviour and fixes the issue for non-standard install paths.
I created a pull request for the second option.
@lukasostendorf - thanks, I'm currently traveling but will review this and the proposed fix in a few weeks.
@tmiw - do you have any comments?
@lukasostendorf - thanks, I'm currently traveling but will review this and the proposed fix in a few weeks.
@tmiw - do you have any comments?
Seems fine to me.