cmake_minimum_required(VERSION 2.6) project(libresample) enable_testing() include(CheckIncludeFiles) include(CheckTypeSize) include(FindPkgConfig) check_type_size("void *" POINTER_SIZE) if(${POINTER_SIZE} EQUAL 8) set(LIBDIR lib64) elseif(${POINTER_SIZE} EQUAL 4) set(LIBDIR lib) else(${POINTER_SIZE} EQUAL 8) message(FATAL_ERROR "pointer size is not 4 bytes or 8 bytes") endif(${POINTER_SIZE} EQUAL 8) check_include_files(inttypes.h HAVE_INTTYPES_H) find_library(HAVE_LIBM m) pkg_check_modules(SNDFILE sndfile) pkg_check_modules(SAMPLERATE samplerate) find_program(DOXYGEN NAMES doxygen) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configtemplate.h ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libresample.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libresample.pc) add_library(resample SHARED src/filterkit.c src/resample.c src/resamplesubs.c) set_target_properties(resample PROPERTIES VERSION 1.0 SOVERSION 1) install(TARGETS resample LIBRARY DESTINATION ${LIBDIR}) install(FILES include/libresample.h DESTINATION include) add_executable(testresample tests/testresample.c) target_link_libraries(testresample resample m) add_test(testresample testresample) if(SNDFILE_FOUND) add_executable(resample-sndfile tests/resample-sndfile.c) target_link_libraries(resample-sndfile resample m) set_target_properties(resample-sndfile PROPERTIES COMPILE_FLAGS "${SNDFILE_CFLAGS}" LINK_FLAGS "${SNDFILE_LDFLAGS}") install(TARGETS resample-sndfile RUNTIME DESTINATION bin) endif(SNDFILE_FOUND) if(SAMPLERATE_FOUND) add_executable(compareresample tests/compareresample.c) target_link_libraries(compareresample resample m) set_target_properties(compareresample PROPERTIES COMPILE_FLAGS "${SAMPLERATE_CFLAGS}" LINK_FLAGS "${SAMPLERATE_LDFLAGS}") add_test(compareresample compareresample) endif(SAMPLERATE_FOUND) install(FILES libresample.pc DESTINATION ${LIBDIR}/pkgconfig) if(DOXYGEN) add_custom_command(OUTPUT docs/html/index.html COMMAND ${DOXYGEN} docs/Doxyfile DEPENDS include/libresample.h) add_custom_target(docs ALL DEPENDS docs/html/index.html) endif(DOXYGEN)