Merge pull request #20 from hasufell/master

Make building examples and tests optional
This commit is contained in:
Andrew Kelley 2015-09-05 11:27:26 -07:00
commit d233757b63

View file

@ -25,6 +25,8 @@ set(LIBSOUNDIO_VERSION "${LIBSOUNDIO_VERSION_MAJOR}.${LIBSOUNDIO_VERSION_MINOR}.
message("Configuring libsoundio version ${LIBSOUNDIO_VERSION}")
option(BUILD_STATIC_LIBS "Build static libraries" ON)
option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON)
option(BUILD_TESTS "Build tests" ON)
option(ENABLE_JACK "Enable JACK backend" ON)
option(ENABLE_PULSEAUDIO "Enable PulseAudio backend" ON)
option(ENABLE_ALSA "Enable ALSA backend" ON)
@ -254,6 +256,7 @@ install(FILES
# Example Programs
if(BUILD_EXAMPLE_PROGRAMS)
add_executable(sio_sine example/sio_sine.c)
set_target_properties(sio_sine PROPERTIES
LINKER_LANGUAGE C
@ -281,7 +284,12 @@ set_target_properties(sio_record PROPERTIES
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(sio_record libsoundio_shared)
install(TARGETS sio_record DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(BUILD_TESTS)
include_directories(
"${CMAKE_SOURCE_DIR}/test"
)
add_executable(unit_tests "${CMAKE_SOURCE_DIR}/test/unit_tests.cpp" ${LIBSOUNDIO_SOURCES})
target_link_libraries(unit_tests LINK_PUBLIC ${LIBSOUNDIO_LIBS})
@ -328,6 +336,8 @@ add_custom_target(coverage
COMMAND genhtml -o coverage coverage.info.cleaned --rc lcov_branch_coverage=1
COMMAND rm coverage.info coverage.info.cleaned
)
endif()
add_custom_target(doc
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
@ -342,6 +352,8 @@ message("\n"
"* Install Directory : ${CMAKE_INSTALL_PREFIX}\n"
"* Build Type : ${CMAKE_BUILD_TYPE}\n"
"* Build static libs : ${BUILD_STATIC_LIBS}\n"
"* Build examples : ${BUILD_EXAMPLE_PROGRAMS}\n"
"* Build tests : ${BUILD_TESTS}\n"
)
message(