I have a fork of C++ CMake application: https://github.com/LTVA1/furnace
This program is capable of producing wav files through libsndfile. However, I want to add an ability to export flac/ogg/mp3/etc. files for user convenience.
But there’s a problem: I can’t properly add libFLAC, libogg and libvorbis to my project. libFLAC errors with “can’t find ogg include” error upon compilation. I used this variation of libogg/libvorbis: https://github.com/Iunusov/OGG-Vorbis-CMAKE.
In main project’s CMakeLists I tried to add the following lines:
was
if (USE_SNDFILE)
became
if (USE_SNDFILE)
set(OGG_LIBRARY ${CMAKE_SOURCE_DIR}/extern/ogg)
set(OGG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extern/ogg/include)
# set(FLAC_LIBRARY extern/flac)
# set(FLAC_INCLUDE_DIR extern/flac/include)
# set(VORBIS_LIBRARY extern/vorbis)
# set(VORBIS_INCLUDE_DIR extern/vorbis/include)
add_subdirectory(extern/ogg EXCLUDE_FROM_ALL)
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/ogg/include)
list(APPEND DEPENDENCIES_LIBRARIES Ogg)
add_subdirectory(extern/vorbis EXCLUDE_FROM_ALL)
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/vorbis/include)
list(APPEND DEPENDENCIES_LIBRARIES Vorbis)
add_subdirectory(extern/flac EXCLUDE_FROM_ALL)
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/flac/include)
list(APPEND DEPENDENCIES_LIBRARIES FLAC)
The problem is that libFLAC requires libogg, libvorbis requires libogg, and libsndfile requires all three: flac/ogg/vorbis. I thought CMake would somehow automatically allow the #include <ogg/ogg.h>
thing to work inside libFLAC/inside my main application. Looks like the libraries are made primarily for usage with some package manager, but I want to just statically link these vendored libraries into my application (user clones git repo without any required packages installation and just builds one binary application which does not have any external dependencies). I believe that this somewhat strict requirement is what complicates the incorporation of all these libraries.
I do not want to use any package manager. I do not want to rely on these libraries to be already installed on user side (as it is rn with libraries that are currently used in the app). I want them to be statically linked and be incorporated into main binary file of the app.
P.S. Little to no CMake experience.
I tried to add libraries to my project, and expected them to work. But they aren’t properly visible in the project, includes error out