I’m trying to vendor https://github.com/taglib/taglib in my project and link against it while keeping possibility to use this library installed in OS. The problem is that this library copies all header files into $PREFIX/include/taglib
upon make install, and then you supposed to do #include <taglib/whatever.h>
when linking against OS-provided lib.
But when I want to build the vendored version I do
set(TAGLIB_DIR 3rdparty/taglib-2.0.2)
add_subdirectory(${TAGLIB_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE tag)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${TAGLIB_DIR}/taglib ${TAGLIB_DIR}/taglib/ape ${TAGLIB_DIR}/taglib/mpeg ${TAGLIB_DIR}/taglib/mpeg/id3v2 ...etc all subdirs with headers)
Cannot just list all subdirectories where headers are located b/c then I have to reference them directly, like #include <id3v2.h>
which is located in taglib/mpeg/id3v2/
. Meanwhile, the same include for OS-wide library is #include <taglib/id3v2.h>
.
Do I really need to do
#ifdef USE_SYSTEM_TAGLIB
#include "taglib/fileref.h"
#include "taglib/tag.h"
#else
#include "fileref.h"
#include "tag.h"
#endif
? b/c this is how I’m doing it in qmake now, and want to switch to cmake to get rid of this.
I’m new to cmake and feel like I’m missing something obvious, but it’s kind of 2nd order unknown. Also, how exactly this library does this copying? Where is it specified to recursively find all headers and copy them into prefix/include?
5