I am trying to use CMake for the first time by making a cross-plaform project (Windows and Linux, but not macOS) with the Taglib library (https://github.com/taglib/taglib).
My problem right now is that I receive the "No such file or directory" error when I build the application using the "make" software. This is because the path to the Taglib header files are not specified to the compiler by the -I option. How can I use the information in the CMake files in the Taglib project to compile with its headers (with the -I option).
Plus, if some of you can give me tips on how to add the Taglib library in a CMake projet in order to make it cross platform it would be much appreciated.
Thanks again, and I mean it a lot!
Project Tree Structure
ProjectName/
|-- Preload.cmake
|-- CMakeLists.txt
|-- main.cpp
|-- taglib/ (This folder is a submodule to my repository. This repository can be found here:
https://github.com/taglib/taglib)
ProjectName/Preload.cmake
if(UNIX AND NOT APPLE)
set (CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
endif()
if(WIN32)
set (CMAKE_GENERATOR "MinGW Makefiles" CACHE INTERNAL "" FORCE)
endif()
ProjectName/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(ProjectName)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_subdirectory(taglib)
# Here I should include the directories of Taglib.
# I am not sure aobut this but I am guessing that it is here that I should
# set some CMake configuration variable or some C++ Pre-compiler definition.
# Here is the installation note (https://github.com/taglib/taglib/blob/master/INSTALL.md).
add_executable(${CMAKE_PROJECT_NAME} main.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} tag)
ProjectName/main.cpp
// Some Taglib included headers
#include <mpegfile.h>
#include ...
#include ...
int main(int argc, char* argv[]) {
// Some code using the taglib library
}