Skip to content

Commit

Permalink
Update libarchive and brew dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Jun 21, 2024
1 parent 2f42ba5 commit d4c2dd3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/scripts/.Aptfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ package 'git'
package 'jq'
package 'ninja-build', bin: 'ninja'
package 'pkg-config'
package 'libarchive-dev'
1 change: 1 addition & 0 deletions .github/scripts/.Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ brew "cmake"
brew "git"
brew "jq"
brew "xcbeautify"
brew "libarchive"
68 changes: 37 additions & 31 deletions cmake/BuildLibarchive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,44 @@ if(WIN32)
add_library(libbzip2 STATIC IMPORTED)
target_include_directories(libbzip2 INTERFACE ${bzip2_SOURCE_DIR})
set_property(TARGET libbzip2 PROPERTY IMPORTED_LOCATION ${bzip2_SOURCE_DIR}/libbz2-static.lib)
endif()

set(LIBARCHIVE_VERSION 3.7.4)
set(LIBARCHIVE_URL "https://github.com/libarchive/libarchive/archive/v${LIBARCHIVE_VERSION}.tar.gz")

ExternalProject_Add(
libarchive-build
URL ${LIBARCHIVE_URL}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DENABLE_TEST=OFF -DBUILD_SHARED_LIBS=ON
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config ${CMAKE_BUILD_TYPE} --target install)

# get the install directory
ExternalProject_Get_Property(libarchive-build INSTALL_DIR)

# create an INTERFACE library to link against
add_library(libarchive INTERFACE)
add_dependencies(libarchive libarchive-build)
target_include_directories(libarchive INTERFACE ${INSTALL_DIR}/include)

add_library(libarchive::libarchive SHARED IMPORTED)
set_property(
TARGET libarchive::libarchive
PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}archive${CMAKE_SHARED_LIBRARY_SUFFIX})
add_dependencies(libarchive::libarchive libarchive-build)
if(WIN32)
set(LIBARCHIVE_VERSION 3.7.4)
set(LIBARCHIVE_URL "https://github.com/libarchive/libarchive/archive/v${LIBARCHIVE_VERSION}.tar.gz")

ExternalProject_Add(
libarchive-build
URL ${LIBARCHIVE_URL}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DENABLE_TEST=OFF -DBUILD_SHARED_LIBS=ON
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config ${CMAKE_BUILD_TYPE} --target install)

# get the install directory
ExternalProject_Get_Property(libarchive-build INSTALL_DIR)

# create an INTERFACE library to link against
add_library(libarchive INTERFACE)
add_dependencies(libarchive libarchive-build)
target_include_directories(libarchive INTERFACE ${INSTALL_DIR}/include)

add_library(libarchive::libarchive SHARED IMPORTED)
set_property(
TARGET libarchive::libarchive
PROPERTY IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}archive${CMAKE_IMPORT_LIBRARY_SUFFIX})
install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}archive${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_SOURCE_DIR}/release/$<CONFIG>/obs-plugins/64bit)
endif()
PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}archive${CMAKE_SHARED_LIBRARY_SUFFIX})
add_dependencies(libarchive::libarchive libarchive-build)
if(WIN32)
set_property(
TARGET libarchive::libarchive
PROPERTY IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}archive${CMAKE_IMPORT_LIBRARY_SUFFIX})
install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}archive${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_SOURCE_DIR}/release/$<CONFIG>/obs-plugins/64bit)
endif()

target_link_libraries(libarchive INTERFACE libarchive::libarchive libbzip2)
target_link_libraries(libarchive INTERFACE libarchive::libarchive libbzip2)
else() # Linux and MacOS - use system libraries
find_package(LibArchive REQUIRED)
find_package(BZip2 REQUIRED)

add_library(libarchive INTERFACE)
target_link_libraries(libarchive INTERFACE LibArchive::LibArchive BZip2::BZip2)
endif()
13 changes: 0 additions & 13 deletions cmake/BuildSherpaOnnx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ elseif(APPLE)
"${SHERPA_ONNX_BASE_URL}/sherpa-onnx-v${SHERPA_ONNX_VERSION}-osx-universal2-shared.tar.bz2")
else()
set(SHERPA_ONNX_DOWNLOAD_URL "${SHERPA_ONNX_BASE_URL}/sherpa-onnx-v${SHERPA_ONNX_VERSION}-linux-x64-shared.tar.bz2")
# include(ExternalProject)

# # Set the repository URL and branch set(SHERPA_ONNX_URL
# "https://github.com/k2-fsa/sherpa-onnx/archive/refs/tags/v${SHERPA_ONNX_VERSION}.tar.gz")

# # Configure the ExternalProject ExternalProject_Add( sherpa-onnx-build URL ${SHERPA_ONNX_URL} BUILD_COMMAND
# ${CMAKE_COMMAND} --build <BINARY_DIR> --config ${CMAKE_BUILD_TYPE} CMAKE_GENERATOR ${CMAKE_GENERATOR}
# INSTALL_COMMAND ${CMAKE_COMMAND} --install <BINARY_DIR> --config ${CMAKE_BUILD_TYPE} CMAKE_ARGS
# -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF -DSHERPA_ONNX_ENABLE_PYTHON=OFF
# -DSHERPA_ONNX_ENABLE_TESTS=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF -DSHERPA_ONNX_ENABLE_BINARY=OFF
# -DBUILD_SHARED_LIBS=ON)

# # Add the include directories ExternalProject_Get_Property(sherpa-onnx-build INSTALL_DIR)
endif()

FetchContent_Declare(sherpa-onnx-build URL ${SHERPA_ONNX_DOWNLOAD_URL})
Expand Down

0 comments on commit d4c2dd3

Please sign in to comment.