From 3aeb2097debb88d894404875507385296eaa93a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sat, 10 Nov 2018 14:00:13 -0500 Subject: [PATCH] cmake: factor the libogg dependency --- CMakeLists.txt | 13 +++++-------- t/CMakeLists.txt | 10 ++-------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adf7e99..93be785 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,9 @@ project( set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -include(FindPkgConfig) +find_package(PkgConfig REQUIRED) pkg_check_modules(OGG REQUIRED ogg) +add_compile_options(${OGG_CFLAGS}) configure_file(src/config.h.in config.h @ONLY) include_directories(BEFORE src "${CMAKE_BINARY_DIR}") @@ -22,14 +23,10 @@ add_library( src/ogg.cc src/opus.cc ) +target_link_libraries(libopustags PUBLIC ${OGG_LIBRARIES}) -add_executable( - opustags - src/opustags.cc - $ -) -target_compile_options(opustags PUBLIC ${OGG_CFLAGS}) -target_link_libraries(opustags PUBLIC ${OGG_LIBRARIES}) +add_executable(opustags src/opustags.cc) +target_link_libraries(opustags libopustags) include(GNUInstallDirs) install(TARGETS opustags DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt index ed6020a..ee0cbe4 100644 --- a/t/CMakeLists.txt +++ b/t/CMakeLists.txt @@ -1,11 +1,5 @@ -add_executable( - unit.t - EXCLUDE_FROM_ALL - unit.cc - $ -) -target_compile_options(unit.t PUBLIC ${OGG_CFLAGS}) -target_link_libraries(unit.t PUBLIC ${OGG_LIBRARIES}) +add_executable(unit.t EXCLUDE_FROM_ALL unit.cc) +target_link_libraries(unit.t libopustags) add_custom_target( check