configure cmake for unit tests

This commit is contained in:
Frédéric Mangano-Tarumi 2018-11-04 18:24:29 -05:00
parent f2a60e4220
commit af988efd8a
3 changed files with 42 additions and 4 deletions

View File

@ -13,13 +13,19 @@ include(FindPkgConfig)
pkg_check_modules(OGG REQUIRED ogg)
configure_file(src/config.h.in config.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(BEFORE src "${CMAKE_BINARY_DIR}")
add_library(
libopustags
OBJECT
src/ogg.cc
src/opus.cc
)
add_executable(
opustags
src/ogg.cc
src/opus.cc
src/opustags.cc
$<TARGET_OBJECTS:libopustags>
)
target_compile_options(opustags PUBLIC ${OGG_CFLAGS})
target_link_libraries(opustags PUBLIC ${OGG_LIBRARIES})
@ -28,4 +34,4 @@ include(GNUInstallDirs)
install(TARGETS opustags DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES opustags.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
add_custom_target(check COMMAND prove "${CMAKE_SOURCE_DIR}/t" DEPENDS opustags)
add_subdirectory(t)

15
t/CMakeLists.txt Normal file
View File

@ -0,0 +1,15 @@
add_executable(
unit.t
EXCLUDE_FROM_ALL
unit.cc
$<TARGET_OBJECTS:libopustags>
)
target_compile_options(unit.t PUBLIC ${OGG_CFLAGS})
target_link_libraries(unit.t PUBLIC ${OGG_LIBRARIES})
add_custom_target(
check
COMMAND prove "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS opustags unit.t
)

17
t/unit.cc Normal file
View File

@ -0,0 +1,17 @@
/**
* \file t/unit.cc
*
* Entry point of the unit test suite.
* Follows the TAP protocol.
*
*/
#include <opustags.h>
#include <iostream>
int main()
{
std::cout << "1..1\nok - trivial\n";
return 0;
}