diff --git a/CMakeLists.txt b/CMakeLists.txt index d9a0b3e..f189e3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/cmake/BuildCTranslate2.cmake b/cmake/BuildCTranslate2.cmake index 3803cf3..dce5aa5 100644 --- a/cmake/BuildCTranslate2.cmake +++ b/cmake/BuildCTranslate2.cmake @@ -1,4 +1,3 @@ - # build the CTranslate2 library from source https://github.com/OpenNMT/CTranslate2.git include(ExternalProject) @@ -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) @@ -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 --config ${CMAKE_BUILD_TYPE} - CMAKE_GENERATOR ${CMAKE_GENERATOR} - INSTALL_COMMAND ${CMAKE_COMMAND} --install --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= - -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 --config ${CMAKE_BUILD_TYPE} + CMAKE_GENERATOR ${CMAKE_GENERATOR} + INSTALL_COMMAND ${CMAKE_COMMAND} --install --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= + -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) diff --git a/cmake/BuildSentencepiece.cmake b/cmake/BuildSentencepiece.cmake index c55cbfb..c16a700 100644 --- a/cmake/BuildSentencepiece.cmake +++ b/cmake/BuildSentencepiece.cmake @@ -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 --config ${CMAKE_BUILD_TYPE} - CMAKE_GENERATOR ${CMAKE_GENERATOR} - INSTALL_COMMAND ${CMAKE_COMMAND} --install --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= - -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 --config ${CMAKE_BUILD_TYPE} + CMAKE_GENERATOR ${CMAKE_GENERATOR} + INSTALL_COMMAND ${CMAKE_COMMAND} --install --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= + -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) diff --git a/src/plugin-main.c b/src/plugin-main.c index 26e97fd..ea69d47 100644 --- a/src/plugin-main.c +++ b/src/plugin-main.c @@ -27,7 +27,7 @@ bool obs_module_load(void) { obs_log(LOG_INFO, "plugin loaded successfully (version %s)", PLUGIN_VERSION); - translate(); + translate(); return true; }