1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-11-10 04:42:50 +01:00

cmake: add 'soundstretch' utility, regroup CMakeList.txt by targets

- add 'soundstretch' utility as cmake build target
- group CMakeList.txt contents per target for better readability
This commit is contained in:
Olli 2021-08-20 21:56:12 +03:00
parent 6dce1068d9
commit 65caafdc5f

View File

@ -3,6 +3,17 @@ project(SoundTouch VERSION 2.2.1 LANGUAGES CXX)
include(GNUInstallDirs) include(GNUInstallDirs)
if(MSVC)
set(COMPILE_DEFINITIONS CMAKE /O2 /fp:fast)
set(COMPILE_OPTIONS )
else()
set(COMPILE_OPTIONS -Ofast)
set(COMPILE_DEFINITIONS CMAKE)
endif()
#####################
# SoundTouch library
add_library(SoundTouch add_library(SoundTouch
source/SoundTouch/AAFilter.cpp source/SoundTouch/AAFilter.cpp
source/SoundTouch/BPMDetect.cpp source/SoundTouch/BPMDetect.cpp
@ -24,21 +35,8 @@ target_include_directories(SoundTouch PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )
option(SOUNDTOUCH_DLL "Build SoundTouchDLL C wrapper library" OFF) target_compile_definitions(SoundTouch PRIVATE ${COMPILE_DEFINITIONS})
if(SOUNDTOUCH_DLL) target_compile_options(SoundTouch PRIVATE ${COMPILE_OPTIONS})
add_library(SoundTouchDLL SHARED
source/SoundTouchDLL/SoundTouchDLL.cpp
source/SoundTouchDLL/SoundTouchDLL.rc
)
target_compile_options(SoundTouch PRIVATE -fPIC)
set_target_properties(SoundTouchDLL PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_compile_options(SoundTouchDLL PRIVATE -Ofast)
target_compile_definitions(SoundTouchDLL PRIVATE CMAKE)
target_include_directories(SoundTouchDLL PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(SoundTouchDLL PRIVATE SoundTouch)
install(FILES source/SoundTouchDLL/SoundTouchDLL.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soundtouch")
install(TARGETS SoundTouchDLL EXPORT SoundTouchTargets)
endif()
if(WIN32 AND BUILD_SHARED_LIBS) if(WIN32 AND BUILD_SHARED_LIBS)
set_target_properties(SoundTouch PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set_target_properties(SoundTouch PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
@ -47,14 +45,6 @@ if(WIN32 AND BUILD_SHARED_LIBS)
endif() endif()
endif() endif()
if(MSVC)
target_compile_definitions(SoundTouch PRIVATE /O2 /fp:fast)
else()
target_compile_options(SoundTouch PRIVATE -Ofast)
endif()
target_compile_definitions(SoundTouch PRIVATE CMAKE)
option(INTEGER_SAMPLES "Use integers instead of floats for samples" OFF) option(INTEGER_SAMPLES "Use integers instead of floats for samples" OFF)
if(INTEGER_SAMPLES) if(INTEGER_SAMPLES)
target_compile_definitions(SoundTouch PRIVATE SOUNDTOUCH_INTEGER_SAMPLES) target_compile_definitions(SoundTouch PRIVATE SOUNDTOUCH_INTEGER_SAMPLES)
@ -89,6 +79,44 @@ install(TARGETS SoundTouch
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
) )
#######################
# soundstretch utility
add_executable(soundstretch
source/SoundStretch/main.cpp
source/SoundStretch/RunParameters.cpp
source/SoundStretch/WavFile.cpp
)
target_include_directories(soundstretch PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_compile_definitions(soundstretch PRIVATE ${COMPILE_DEFINITIONS})
target_compile_options(soundstretch PRIVATE ${COMPILE_OPTIONS})
target_link_libraries(soundstretch PRIVATE SoundTouch)
install(TARGETS soundstretch
DESTINATION bin
)
########################
# SoundTouchDll library
option(SOUNDTOUCH_DLL "Build SoundTouchDLL C wrapper library" OFF)
if(SOUNDTOUCH_DLL)
add_library(SoundTouchDLL SHARED
source/SoundTouchDLL/SoundTouchDLL.cpp
source/SoundTouchDLL/SoundTouchDLL.rc
)
target_compile_options(SoundTouch PRIVATE -fPIC)
target_compile_options(SoundTouchDLL PRIVATE -fPIC ${COMPILE_OPTIONS})
target_compile_definitions(SoundTouchDLL PRIVATE ${COMPILE_DEFINITIONS})
set_target_properties(SoundTouchDLL PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_include_directories(SoundTouchDLL PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(SoundTouchDLL PRIVATE SoundTouch)
install(FILES source/SoundTouchDLL/SoundTouchDLL.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soundtouch")
install(TARGETS SoundTouchDLL EXPORT SoundTouchTargets)
endif()
########################
# pkgconfig # pkgconfig
set(prefix "${CMAKE_INSTALL_PREFIX}") set(prefix "${CMAKE_INSTALL_PREFIX}")
set(execprefix "\${prefix}") set(execprefix "\${prefix}")