mardi 16 octobre 2018

How to make CMake path independent

I have a project with the following CMake file:

set(CMAKE_VERBOSE_MAKEFILE ON)
cmake_minimum_required(VERSION 3.12)
project(mp3_tagger)
set(CMAKE_CXX_STANDARD 11)
find_package(Boost 1.67 COMPONENTS program_options filesystem REQUIRED)

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS)

set(SOURCE_FILES src/main.cpp src/Parser.cpp include/Parser.h src/Tagger.cpp include/Tagger.h)
add_executable(mp3_tagger ${SOURCE_FILES})
target_link_libraries(mp3_tagger ${Boost_LIBRARIES} -L/usr/local/Cellar/taglib/1.11.1/lib -ltag)

I would want to make it work independently from where the library has been installed (essentially i want to remove the hard coded path -L/usr/local/Cellar/taglib/1.11.1/lib) so that the CMake could work on a different machine that might have the library in a different folder like it is for Boost.

Is there a way to do so or the only way would be to modify the file?

Aucun commentaire:

Enregistrer un commentaire