[soundtouch] Use CMake

This commit is contained in:
Robert Schumacher 2018-03-24 15:00:47 -07:00
parent e8d1666d9c
commit 21909157e2
3 changed files with 44 additions and 46 deletions

View File

@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.5)
project(soundtouch CXX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH_SUFFIX _x64)
else()
set(ARCH_SUFFIX)
endif()
if(BUILD_SHARED_LIBS)
set(TYPE_SUFFIX Dll)
else()
set(TYPE_SUFFIX $<$<Config:Debug>:D>)
endif()
file(GLOB SOUNDTOUCH_SOURCES source/SoundTouch/*.cpp)
add_library(libsoundtouch ${SOUNDTOUCH_SOURCES})
target_include_directories(libsoundtouch PUBLIC include)
set_target_properties(libsoundtouch PROPERTIES OUTPUT_NAME SoundTouch${TYPE_SUFFIX}${ARCH_SUFFIX})
if(BUILD_SHARED_LIBS)
target_compile_definitions(libsoundtouch PRIVATE -DDLL_EXPORTS)
target_sources(libsoundtouch PRIVATE
source/SoundTouchDLL/SoundTouchDLL.cpp
source/SoundTouchDLL/SoundTouchDLL.rc
)
endif()
install(TARGETS libsoundtouch
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

View File

@ -1,4 +1,4 @@
Source: soundtouch
Version: 2.0.0
Version: 2.0.0-1
Description: SoundTouch is an open-source audio processing library for changing the Tempo, Pitch and Playback Rates of audio streams or audio files.
Build-Depends: atlmfc

View File

@ -1,11 +1,15 @@
include(vcpkg_common_functions)
# NOTE: SoundTouch has a static c++ version too, but entirely different headers, api, etc
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(STATUS "Warning: Static building not supported. Building dynamic.")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
if(VCPKG_CRT_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Refusing to build DLL with static CRT linkage.")
endif()
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(FATAL_ERROR "WindowsStore not supported")
endif()
@ -18,56 +22,18 @@ vcpkg_download_distfile(ARCHIVE
FILENAME "soundtouch-${VERSION}.zip"
SHA512 50ef36b6cd21c16e235b908c5518e29b159b11f658a014c47fe767d3d8acebaefefec0ce253b4ed322cbd26387c69c0ed464ddace0c098e61d56d55c198117a5
)
# MSBuild performs in-source builds, so to ensure reliability we must clear them each time
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src)
vcpkg_extract_source_archive(${ARCHIVE})
vcpkg_execute_required_process(
COMMAND "devenv.exe"
"SoundTouchDLL.sln"
/Upgrade
WORKING_DIRECTORY ${SOURCE_PATH}/source/SoundTouchDLL
LOGNAME upgrade-Packet-${TARGET_TRIPLET}
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
IF (TRIPLET_SYSTEM_ARCH MATCHES "x64")
# There is no x64 Debug target
SET(BUILD_RELEASE_CONFIGURATION "ReleaseX64")
SET(BUILD_DEBUG_CONFIGURATION "ReleaseX64")
ELSE()
SET(BUILD_RELEASE_CONFIGURATION "Release")
SET(BUILD_DEBUG_CONFIGURATION "Debug")
ENDIF()
SET(BUILD_ARCH "Win32")
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/source/SoundTouchDLL/SoundTouchDLL.sln
PLATFORM ${BUILD_ARCH}
RELEASE_CONFIGURATION ${BUILD_RELEASE_CONFIGURATION}
DEBUG_CONFIGURATION ${BUILD_DEBUG_CONFIGURATION}
)
vcpkg_install_cmake()
file(INSTALL ${SOURCE_PATH}/source/SoundTouchDLL/SoundTouchDLL.h DESTINATION ${CURRENT_PACKAGES_DIR}/include)
# Handle libraries
IF (BUILD_RELEASE_CONFIGURATION STREQUAL ReleaseX64)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouch_x64.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouchDll_x64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
ELSE()
file(INSTALL ${SOURCE_PATH}/lib/SoundTouch.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouchDll.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
ENDIF()
IF (BUILD_DEBUG_CONFIGURATION STREQUAL ReleaseX64)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouch_x64.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouchDll_x64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
ELSE()
file(INSTALL ${SOURCE_PATH}/lib/SoundTouchD.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
file(INSTALL ${SOURCE_PATH}/lib/SoundTouchDllD.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
ENDIF()
file(COPY ${SOURCE_PATH}/COPYING.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/soundtouch)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/soundtouch/COPYING.TXT ${CURRENT_PACKAGES_DIR}/share/soundtouch/copyright)