Skip to content

Commit 4cc3e43

Browse files
authored
Merge pull request #1536 from zh794390558/cmake
[speechx] libsndfile
2 parents eb4826f + 6c0af89 commit 4cc3e43

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

speechx/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ include(gtest)
5353
# ABSEIL-CPP
5454
include(absl)
5555

56-
# libsndfile, not work
57-
#include(libsndfile)
56+
# libsndfile
57+
include(libsndfile)
5858

5959
# boost
6060
set(boost_SOURCE_DIR ${fc_patch}/boost-src)
Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
11
include(FetchContent)
22

3+
# https://github.com/pongasoft/vst-sam-spl-64/blob/master/libsndfile.cmake
4+
# https://github.com/popojan/goban/blob/master/CMakeLists.txt#L38
5+
# https://github.com/ddiakopoulos/libnyquist/blob/master/CMakeLists.txt
6+
7+
if(LIBSNDFILE_ROOT_DIR)
8+
# instructs FetchContent to not download or update but use the location instead
9+
set(FETCHCONTENT_SOURCE_DIR_LIBSNDFILE ${LIBSNDFILE_ROOT_DIR})
10+
else()
11+
set(FETCHCONTENT_SOURCE_DIR_LIBSNDFILE "")
12+
endif()
313

414
set(LIBSNDFILE_GIT_REPO "https://github.com/erikd/libsndfile" CACHE STRING "libsndfile git repository url" FORCE)
5-
set(LIBSNDFILE_GIT_TAG 1.0.31 CACHE STRING "libsndfile git tag" FORCE)
15+
set(LIBSNDFILE_GIT_TAG c11deaa04ec84161996824061f6d705970972e2e CACHE STRING "libsndfile git tag" FORCE)
616

717
FetchContent_Declare(libsndfile
818
GIT_REPOSITORY ${LIBSNDFILE_GIT_REPO}
919
GIT_TAG ${LIBSNDFILE_GIT_TAG}
10-
CMAKE_ARGS "-G"Unix Makefiles""
20+
GIT_CONFIG advice.detachedHead=false
21+
# GIT_SHALLOW true
22+
CONFIGURE_COMMAND ""
1123
BUILD_COMMAND ""
1224
INSTALL_COMMAND ""
1325
TEST_COMMAND ""
1426
)
1527

16-
17-
set(BUILD_SHARED_LIBS ON)
18-
FetchContent_MakeAvailable(libsndfile)
19-
28+
FetchContent_GetProperties(libsndfile)
29+
if(NOT libsndfile_POPULATED)
30+
if(FETCHCONTENT_SOURCE_DIR_LIBSNDFILE)
31+
message(STATUS "Using libsndfile from local ${FETCHCONTENT_SOURCE_DIR_LIBSNDFILE}")
32+
else()
33+
message(STATUS "Fetching libsndfile ${LIBSNDFILE_GIT_REPO}/tree/${LIBSNDFILE_GIT_TAG}")
34+
endif()
35+
FetchContent_Populate(libsndfile)
36+
endif()
2037

2138
set(LIBSNDFILE_ROOT_DIR ${libsndfile_SOURCE_DIR})
2239
set(LIBSNDFILE_INCLUDE_DIR "${libsndfile_BINARY_DIR}/src")
2340

24-
#file(COPY "${libsndfile_SOURCE_DIR}/src/sndfile.hh" DESTINATION ${LIBSNDFILE_INCLUDE_DIR})
41+
function(libsndfile_build)
42+
option(BUILD_PROGRAMS "Build programs" OFF)
43+
option(BUILD_EXAMPLES "Build examples" OFF)
44+
option(BUILD_TESTING "Build examples" OFF)
45+
option(ENABLE_CPACK "Enable CPack support" OFF)
46+
option(ENABLE_PACKAGE_CONFIG "Generate and install package config file" OFF)
47+
option(BUILD_REGTEST "Build regtest" OFF)
48+
# finally we include libsndfile itself
49+
add_subdirectory(${libsndfile_SOURCE_DIR} ${libsndfile_BINARY_DIR} EXCLUDE_FROM_ALL)
50+
# copying .hh for c++ support
51+
file(COPY "${libsndfile_SOURCE_DIR}/src/sndfile.hh" DESTINATION ${LIBSNDFILE_INCLUDE_DIR})
52+
endfunction()
53+
54+
libsndfile_build()
2555

2656
include_directories(${LIBSNDFILE_INCLUDE_DIR})

0 commit comments

Comments
 (0)