From 712c80558eb5a70deccb47e4eb75ba2e34348a38 Mon Sep 17 00:00:00 2001 From: Shirasawa <764798966@qq.com> Date: Tue, 12 Dec 2023 01:47:15 +0800 Subject: [PATCH] Fix windows build --- CMakeLists.txt | 26 ++++++++++++++++---------- sleef | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 896f68a..adce5e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,14 @@ set(CMAKE_CXX_STANDARD 23) add_definitions(-DNO_TIMING) set(BUILD_TESTING OFF CACHE BOOL "" FORCE) +set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) +set(SOUNDSTRETCH OFF CACHE BOOL "" FORCE) if (WIN32) - add_definitions(-D_WIN32 -DNOMINMAX -D_USE_MATH_DEFINES -DHAVE_SLEEF -DHAVE_LIBSAMPLERATE -DGETOPT_API=0) + add_definitions(-D_WIN32 -DNOMINMAX -D_USE_MATH_DEFINES -DHAVE_SLEEF -DHAVE_LIBSAMPLERATE -DGETOPT_API=0 -DSLEEF_STATIC_LIBS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD") elseif (LINUX) - add_definitions(-DUSE_PTHREADS -DHAVE_LIBSAMPLERATE -DHAVE_SLEEF -DHAVE_POSIX_MEMALIGN) + add_definitions(-DUSE_PTHREADS -DHAVE_LIBSAMPLERATE -DHAVE_SLEEF -DHAVE_POSIX_MEMALIGN -DSLEEF_STATIC_LIBS) elseif (APPLE) add_definitions(-DHAVE_LIBSAMPLERATE -DHAVE_VDSP -DNO_THREAD_CHECKS -DUSE_PTHREADS -DMALLOC_IS_ALIGNED) endif () @@ -21,6 +23,7 @@ if (WIN32 OR LINUX) set(sleef_BINARY_DIR ${CMAKE_BINARY_DIR}/sleef) set(BUILD_DFT ON CACHE BOOL "" FORCE) set(BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(ENABLE_LTO ON CACHE BOOL "" FORCE) add_subdirectory("sleef") include_directories(${sleef_BINARY_DIR}/include) include_directories(${sleef_SOURCE_DIR}/include) @@ -41,7 +44,6 @@ add_subdirectory(libsamplerate) add_subdirectory(soundtouch) include_directories(stubs) -file(GLOB_RECURSE SRC_FILES lib/*.cpp lib/*.h) file(GLOB_RECURSE RUBBERBAND_SRC_FILES rubberband/src/common/*.cpp rubberband/src/common/*.h rubberband/src/finer/*.cpp rubberband/src/finer/*.h @@ -49,16 +51,20 @@ file(GLOB_RECURSE RUBBERBAND_SRC_FILES rubberband/src/ext/*.cpp rubberband/src/ext/*.h rubberband/rubberband/RubberBandStretcher.h rubberband/src/RubberBandStretcher.cpp ) +add_library(rubberband STATIC ${RUBBERBAND_SRC_FILES}) +target_link_libraries(rubberband PRIVATE samplerate) -add_library(EIMTimeStretchers SHARED ${SRC_FILES} ${RUBBERBAND_SRC_FILES}) -#add_executable(EIMTimeStretchers ${SRC_FILES} ${RUBBERBAND_SRC_FILES}) +file(GLOB_RECURSE SRC_FILES lib/*.cpp lib/*.h) +add_library(EIMTimeStretchers SHARED ${SRC_FILES}) +#add_executable(EIMTimeStretchers ${SRC_FILES}) if (WIN32) - add_dependencies(EIMTimeStretchers sleef) - target_link_libraries(EIMTimeStretchers PRIVATE SoundTouch sleef sleefdft samplerate) + add_dependencies(rubberband sleef) + target_link_libraries(rubberband PRIVATE sleef sleefdft) + target_link_libraries(EIMTimeStretchers PRIVATE SoundTouch rubberband) elseif (APPLE) - target_link_libraries(EIMTimeStretchers PRIVATE "-framework Accelerate" SoundTouch pthread samplerate) + target_link_libraries(EIMTimeStretchers PRIVATE "-framework Accelerate" SoundTouch pthread rubberband) elseif (LINUX) - add_dependencies(EIMTimeStretchers sleef) - target_link_libraries(EIMTimeStretchers PRIVATE SoundTouch sleef sleefdft samplerate) + add_dependencies(rubberband sleef) + target_link_libraries(EIMTimeStretchers PRIVATE SoundTouch rubberband) endif () diff --git a/sleef b/sleef index 7d0b37d..a3754a8 160000 --- a/sleef +++ b/sleef @@ -1 +1 @@ -Subproject commit 7d0b37d1f1f278d214dd362edaa0c70308cbb016 +Subproject commit a3754a8cd57b8915211e2b73661e5d8bbfd8ec4a