Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Oct 19, 2023
1 parent e5a98ed commit f12c5fb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ if(ENABLE_QT)
AUTORCC ON)
endif()

target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/translation.cpp src/plugin-main.c )
target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/translation.cpp src/plugin-main.c)

set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
76 changes: 37 additions & 39 deletions cmake/BuildCTranslate2.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# build the CTranslate2 library from source https://github.com/OpenNMT/CTranslate2.git

include(ExternalProject)
Expand All @@ -8,9 +7,9 @@ include(FetchContent)
set(OpenBLAS_URL "https://github.com/xianyi/OpenBLAS/releases/download/v0.3.24/OpenBLAS-0.3.24-x64.zip")
set(OpenBLAS_SHA256 "6335128ee7117ea2dd2f5f96f76dafc17256c85992637189a2d5f6da0c608163")
FetchContent_Declare(
openblas
URL ${OpenBLAS_URL}
URL_HASH SHA256=${OpenBLAS_SHA256})
openblas
URL ${OpenBLAS_URL}
URL_HASH SHA256=${OpenBLAS_SHA256})
FetchContent_MakeAvailable(openblas)
set(OpenBLAS_DIR ${openblas_SOURCE_DIR})
set(OPENBLAS_INCLUDE_DIR ${OpenBLAS_DIR}/include)
Expand All @@ -23,48 +22,47 @@ set(CT2_VERSION "3.20.0")
set(CT2_URL "https://github.com/OpenNMT/CTranslate2.git")

ExternalProject_Add(
ct2_build
DOWNLOAD_EXTRACT_TIMESTAMP true
GIT_REPOSITORY ${CT2_URL}
GIT_TAG v${CT2_VERSION}
GIT_PROGRESS 1
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_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=ON
-DWITH_CUDA=OFF
-DWITH_MKL=OFF
-DWITH_OPENBLAS=ON
-DOPENMP_RUNTIME=COMP
-DWITH_TESTS=OFF
-DWITH_EXAMPLES=OFF
-DWITH_TFLITE=OFF
-DWITH_TRT=OFF
-DWITH_PYTHON=OFF
-DWITH_SERVER=OFF
-DWITH_COVERAGE=OFF
-DWITH_PROFILING=OFF
-DBUILD_CLI=OFF
-DOPENBLAS_INCLUDE_DIR=${OPENBLAS_INCLUDE_DIR}
-DOPENBLAS_LIBRARY=${OpenBLAS_DIR}/lib/libopenblas.dll.a)
ct2_build
DOWNLOAD_EXTRACT_TIMESTAMP true
GIT_REPOSITORY ${CT2_URL}
GIT_TAG v${CT2_VERSION}
GIT_PROGRESS 1
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_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=ON
-DWITH_CUDA=OFF
-DWITH_MKL=OFF
-DWITH_OPENBLAS=ON
-DOPENMP_RUNTIME=COMP
-DWITH_TESTS=OFF
-DWITH_EXAMPLES=OFF
-DWITH_TFLITE=OFF
-DWITH_TRT=OFF
-DWITH_PYTHON=OFF
-DWITH_SERVER=OFF
-DWITH_COVERAGE=OFF
-DWITH_PROFILING=OFF
-DBUILD_CLI=OFF
-DOPENBLAS_INCLUDE_DIR=${OPENBLAS_INCLUDE_DIR}
-DOPENBLAS_LIBRARY=${OpenBLAS_DIR}/lib/libopenblas.dll.a)
ExternalProject_Get_Property(ct2_build INSTALL_DIR)

add_library(ct2::ct2 SHARED IMPORTED GLOBAL)
set_target_properties(
ct2::ct2
PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}ctranslate2${CMAKE_SHARED_LIBRARY_SUFFIX})
ct2::ct2 PROPERTIES IMPORTED_LOCATION
${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}ctranslate2${CMAKE_SHARED_LIBRARY_SUFFIX})
set_target_properties(
ct2::ct2
PROPERTIES IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}ctranslate2${CMAKE_STATIC_LIBRARY_SUFFIX})
ct2::ct2 PROPERTIES IMPORTED_IMPLIB
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}ctranslate2${CMAKE_STATIC_LIBRARY_SUFFIX})

install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}ctranslate2${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION "obs-plugins/64bit")
DESTINATION "obs-plugins/64bit")

add_library(ct2 INTERFACE)
add_dependencies(ct2 ct2_build)
Expand Down
39 changes: 19 additions & 20 deletions cmake/BuildSentencepiece.cmake
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@

# build sentencepiece from "https://github.com/google/sentencepiece.git"

include(ExternalProject)

set(SP_URL "https://github.com/google/sentencepiece.git" CACHE STRING "URL of sentencepiece repository")
set(SP_URL
"https://github.com/google/sentencepiece.git"
CACHE STRING "URL of sentencepiece repository")

ExternalProject_Add(
sentencepiece_build
DOWNLOAD_EXTRACT_TIMESTAMP true
GIT_REPOSITORY ${SP_URL}
GIT_TAG v0.1.99
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_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
sentencepiece_build
DOWNLOAD_EXTRACT_TIMESTAMP true
GIT_REPOSITORY ${SP_URL}
GIT_TAG v0.1.99
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_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
ExternalProject_Get_Property(sentencepiece_build INSTALL_DIR)

add_library(libsentencepiece SHARED IMPORTED GLOBAL)
set_target_properties(
libsentencepiece
PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sentencepiece${CMAKE_SHARED_LIBRARY_SUFFIX})
libsentencepiece
PROPERTIES IMPORTED_LOCATION
${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sentencepiece${CMAKE_SHARED_LIBRARY_SUFFIX})
set_target_properties(
libsentencepiece
PROPERTIES IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
libsentencepiece
PROPERTIES IMPORTED_IMPLIB
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})

add_library(sentencepiece INTERFACE)
add_dependencies(sentencepiece sentencepiece_build)
Expand Down
2 changes: 1 addition & 1 deletion src/plugin-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool obs_module_load(void)
{
obs_log(LOG_INFO, "plugin loaded successfully (version %s)",
PLUGIN_VERSION);
translate();
translate();
return true;
}

Expand Down

0 comments on commit f12c5fb

Please sign in to comment.