How to link multiple similar libraries at once in cmake

69 Views Asked by At

I am quite new to cmake and have a question what is the best way to achieve this:

I need to link my code against three libraries from cpp-netlib:

cppnetlib-uri
cppnetlib-server-parsers
cppnetlib-client-connections

This is how my CMakeLists.txt currently looks like:

cmake_minimum_required(VERSION 2.6)
project(Songkick_API_call)

set(SOURCE_DIR src)
add_subdirectory(${SOURCE_DIR})

find_library(CPPNETLIB_URI cppnetlib-uri)
find_library(CPPNETLIB_SERVER cppnetlib-server-parsers)
find_library(CPPNETLIB_CON cppnetlib-client-connections)

add_executable(Songkick_API_call ${SOURCE_DIR}/test.cpp)
target_link_libraries(Songkick_API_call ${CPPNETLIB_URI} 
${CPPNETLIB_SERVER} ${CPPNETLIB_CON} pthread)

It is working, but calling find_library three times looks wrong. How should this be done?

0

There are 0 best solutions below