2017-06-29 04:56:24 +08:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
|
|
|
project(aubio C)
|
|
|
|
|
2021-03-26 03:36:00 +08:00
|
|
|
option(WITH_DEPENDENCIES "Adds extra dependencies" ON)
|
2021-06-11 02:23:14 +08:00
|
|
|
option(BUILD_TOOLS "Build and install tools" ON)
|
2021-03-26 03:36:00 +08:00
|
|
|
|
2017-06-29 04:56:24 +08:00
|
|
|
add_definitions(
|
|
|
|
-DHAVE_STDLIB_H=1
|
|
|
|
-DHAVE_STDIO_H=1
|
|
|
|
-DHAVE_MATH_H=1
|
|
|
|
-DHAVE_STRING_H=1
|
|
|
|
-DHAVE_LIMITS_H=1
|
|
|
|
-DHAVE_STDARG_H=1
|
2021-03-26 03:36:00 +08:00
|
|
|
-DHAVE_ERRNO_H=1
|
2017-06-29 04:56:24 +08:00
|
|
|
-DHAVE_C99_VARARGS_MACROS=1
|
2017-11-17 11:03:49 +08:00
|
|
|
-D_CRT_SECURE_NO_WARNINGS=1
|
2017-06-29 04:56:24 +08:00
|
|
|
)
|
|
|
|
|
2021-06-11 02:23:14 +08:00
|
|
|
if(WITH_DEPENDENCIES)
|
|
|
|
add_definitions(
|
|
|
|
-DHAVE_SNDFILE=1
|
|
|
|
-DHAVE_WAVWRITE=1
|
|
|
|
-DHAVE_WAVREAD=1
|
|
|
|
-DHAVE_LIBAV=1
|
|
|
|
-DHAVE_SWRESAMPLE=1
|
|
|
|
)
|
|
|
|
endif()
|
2021-03-26 03:36:00 +08:00
|
|
|
|
2017-06-29 04:56:24 +08:00
|
|
|
set(TOOLS_INSTALLDIR "bin" CACHE STRING "Target directory for installed tools")
|
|
|
|
|
2021-03-26 03:36:00 +08:00
|
|
|
if(WITH_DEPENDENCIES)
|
2021-06-11 02:23:14 +08:00
|
|
|
find_package(FFMPEG COMPONENTS avcodec avutil avformat swresample REQUIRED)
|
2021-03-26 03:36:00 +08:00
|
|
|
find_package(BZip2 REQUIRED)
|
|
|
|
find_package(LibLZMA REQUIRED)
|
|
|
|
find_package(SndFile REQUIRED)
|
|
|
|
|
|
|
|
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
|
|
|
endif()
|
2017-06-29 04:56:24 +08:00
|
|
|
|
2021-03-26 03:36:00 +08:00
|
|
|
include_directories(src)
|
2017-06-29 04:56:24 +08:00
|
|
|
|
|
|
|
file(GLOB_RECURSE SOURCES src/*.c)
|
|
|
|
|
2021-03-26 03:36:00 +08:00
|
|
|
if(WIN32 AND NOT MINGW)
|
|
|
|
set_source_files_properties(src/io/sink_wavwrite.c PROPERTIES COMPILE_FLAGS /FIWinsock2.h)
|
|
|
|
endif()
|
|
|
|
|
2017-06-29 04:56:24 +08:00
|
|
|
add_library(aubio ${SOURCES})
|
2021-03-26 03:36:00 +08:00
|
|
|
if(WITH_DEPENDENCIES)
|
|
|
|
target_link_libraries(aubio PUBLIC
|
|
|
|
SndFile::sndfile
|
|
|
|
${FFMPEG_LIBRARIES}
|
|
|
|
BZip2::BZip2
|
|
|
|
${LIBLZMA_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
2017-06-29 04:56:24 +08:00
|
|
|
|
2021-06-16 01:27:52 +08:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(aubio PUBLIC ws2_32)
|
|
|
|
endif()
|
|
|
|
|
2021-03-26 03:36:00 +08:00
|
|
|
if(BUILD_TOOLS AND WITH_DEPENDENCIES)
|
2017-06-29 04:56:24 +08:00
|
|
|
set(EXAMPLE_EXECS aubiomfcc aubionotes aubioonset aubiopitch aubioquiet aubiotrack)
|
|
|
|
foreach(EXAMPLE_EXEC ${EXAMPLE_EXECS})
|
|
|
|
add_executable(${EXAMPLE_EXEC} examples/${EXAMPLE_EXEC}.c examples/utils.c examples/jackio.c)
|
|
|
|
target_link_libraries(${EXAMPLE_EXEC} PRIVATE aubio)
|
2021-03-26 03:36:00 +08:00
|
|
|
if(WIN32)
|
|
|
|
target_compile_definitions(${EXAMPLE_EXEC} PRIVATE -DHAVE_WIN_HACKS=1)
|
2021-06-16 01:27:52 +08:00
|
|
|
target_link_libraries(${EXAMPLE_EXEC} PUBLIC ws2_32)
|
2021-03-26 03:36:00 +08:00
|
|
|
else()
|
|
|
|
target_compile_definitions(${EXAMPLE_EXEC} PRIVATE -DHAVE_UNISTD_H=1)
|
|
|
|
endif()
|
2017-06-29 04:56:24 +08:00
|
|
|
endforeach()
|
2019-05-03 13:57:43 +08:00
|
|
|
# Create and add fake config.h to avoid build errors (file is generated for
|
2017-06-29 22:23:50 +08:00
|
|
|
# cross-platform requirements in waf build-system)
|
|
|
|
file(WRITE "${CMAKE_BINARY_DIR}/config.h" "")
|
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
2017-06-29 04:56:24 +08:00
|
|
|
|
|
|
|
install(
|
|
|
|
TARGETS ${EXAMPLE_EXECS}
|
|
|
|
RUNTIME DESTINATION ${TOOLS_INSTALLDIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(
|
|
|
|
TARGETS aubio
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT DISABLE_INSTALL_HEADERS)
|
|
|
|
install(
|
|
|
|
DIRECTORY src/
|
|
|
|
DESTINATION include/aubio
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*_priv.h" EXCLUDE
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
endif()
|