Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Oct 24, 2023
1 parent a86b577 commit 74daf59
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 44 deletions.
61 changes: 29 additions & 32 deletions cmake/BuildCTranslate2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
include(ExternalProject)
include(FetchContent)

if (APPLE)
if(APPLE)

FetchContent_Declare(
ctranslate2_fetch
URL https://github.com/obs-ai/obs-ai-ctranslate2-dep/releases/download/1.0.0/libctranslate2-macos-Release-1.0.0.tar.gz
URL_HASH SHA256=8e55a6ed4fb17ac556ad0e020ddab619584e3ceb4c9497a816f819bd8fd36443
)
URL_HASH SHA256=8e55a6ed4fb17ac556ad0e020ddab619584e3ceb4c9497a816f819bd8fd36443)
FetchContent_MakeAvailable(ctranslate2_fetch)

add_library(ct2 INTERFACE)
target_link_libraries(ct2 INTERFACE "-framework Accelerate"
${ctranslate2_fetch_SOURCE_DIR}/lib/libctranslate2.a
${ctranslate2_fetch_SOURCE_DIR}/lib/libcpu_features.a
)
target_link_libraries(ct2 INTERFACE "-framework Accelerate" ${ctranslate2_fetch_SOURCE_DIR}/lib/libctranslate2.a
${ctranslate2_fetch_SOURCE_DIR}/lib/libcpu_features.a)
set_target_properties(ct2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${ctranslate2_fetch_SOURCE_DIR}/include)
target_compile_options(ct2 INTERFACE -Wno-shorten-64-to-32)

Expand Down Expand Up @@ -50,7 +47,7 @@ else()
if(UNIX)
if(APPLE)
set(CT2_CMAKE_PLATFORM_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DBUILD_SHARED_LIBS=OFF -DWITH_ACCELERATE=ON
-DOPENMP_RUNTIME=NONE -DCMAKE_OSX_ARCHITECTURES=arm64)
-DOPENMP_RUNTIME=NONE -DCMAKE_OSX_ARCHITECTURES=arm64)
else()
set(CT2_CMAKE_PLATFORM_OPTIONS -DBUILD_SHARED_LIBS=OFF -DOPENMP_RUNTIME=NONE -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
endif()
Expand All @@ -70,32 +67,28 @@ else()
INSTALL_COMMAND ${CMAKE_COMMAND} --install <BINARY_DIR> --config ${CMAKE_BUILD_TYPE}
BUILD_BYPRODUCTS <INSTALL_DIR>/${CT2_LIB_INSTALL_LOCATION}
CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DWITH_CUDA=OFF
-DWITH_MKL=OFF
-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
${CT2_OPENBLAS_CMAKE_ARGS}
${CT2_CMAKE_PLATFORM_OPTIONS})
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DWITH_CUDA=OFF
-DWITH_MKL=OFF
-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
${CT2_OPENBLAS_CMAKE_ARGS}
${CT2_CMAKE_PLATFORM_OPTIONS})
ExternalProject_Get_Property(ct2_build INSTALL_DIR)

if(UNIX)
# Get cpu_features from the CTranslate2 build - only for x86_64 builds
# if(APPLE)
# ExternalProject_Get_Property(ct2_build BINARY_DIR)
# add_library(ct2::cpu_features STATIC IMPORTED GLOBAL)
# set_target_properties(
# ct2::cpu_features PROPERTIES IMPORTED_LOCATION
# ${BINARY_DIR}/third_party/cpu_features/RelWithDebInfo/libcpu_features.a)
# endif()
# Get cpu_features from the CTranslate2 build - only for x86_64 builds if(APPLE)
# ExternalProject_Get_Property(ct2_build BINARY_DIR) add_library(ct2::cpu_features STATIC IMPORTED GLOBAL)
# set_target_properties( ct2::cpu_features PROPERTIES IMPORTED_LOCATION
# ${BINARY_DIR}/third_party/cpu_features/RelWithDebInfo/libcpu_features.a) endif()

add_library(ct2::ct2 STATIC IMPORTED GLOBAL)
else()
Expand All @@ -110,7 +103,11 @@ else()

add_library(ct2 INTERFACE)
if(APPLE)
target_link_libraries(ct2 INTERFACE "-framework Accelerate /Users/roy_shilkrot/Downloads/obs-ai-ctranslate2-dep/CTranslate2-3.20.0/release/universal/RelWithDebInfo/lib/libctranslate2.a")
target_link_libraries(
ct2
INTERFACE
"-framework Accelerate /Users/roy_shilkrot/Downloads/obs-ai-ctranslate2-dep/CTranslate2-3.20.0/release/universal/RelWithDebInfo/lib/libctranslate2.a"
)
else()
target_link_libraries(ct2 INTERFACE ct2::ct2)
endif()
Expand Down
23 changes: 11 additions & 12 deletions cmake/BuildSentencepiece.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# build sentencepiece from "https://github.com/google/sentencepiece.git"


if(APPLE)

include(FetchContent)

FetchContent_Declare(
sentencepiece_fetch
URL https://github.com/obs-ai/obs-ai-ctranslate2-dep/releases/download/1.0.0/libsentencepiece-macos-Release-1.0.0.tar.gz
URL_HASH SHA256=67f58a8e97c14db1bc69becd507ffe69326948f371bf874fe919157d7d65aff4
)
URL_HASH SHA256=67f58a8e97c14db1bc69becd507ffe69326948f371bf874fe919157d7d65aff4)
FetchContent_MakeAvailable(sentencepiece_fetch)
add_library(sentencepiece INTERFACE)
target_link_libraries(sentencepiece INTERFACE ${sentencepiece_fetch_SOURCE_DIR}/lib/libsentencepiece.a)
set_target_properties(sentencepiece PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${sentencepiece_fetch_SOURCE_DIR}/include)
set_target_properties(sentencepiece PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${sentencepiece_fetch_SOURCE_DIR}/include)

else()

Expand All @@ -24,13 +23,14 @@ else()
if(UNIX)
set(SP_CMAKE_PLATFORM_OPTIONS -DSPM_ENABLE_SHARED=OFF)
if(APPLE)
set(SP_CMAKE_PLATFORM_OPTIONS "${SP_CMAKE_PLATFORM_OPTIONS}"
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13)
set(SP_CMAKE_PLATFORM_OPTIONS "${SP_CMAKE_PLATFORM_OPTIONS}" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13)
endif()
set(SENTENCEPIECE_INSTALL_LIB_LOCATION lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SENTENCEPIECE_INSTALL_LIB_LOCATION
lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(SP_CMAKE_PLATFORM_OPTIONS "")
set(SENTENCEPIECE_INSTALL_LIB_LOCATION bin/${CMAKE_SHARED_LIBRARY_PREFIX}sentencepiece${CMAKE_SHARED_LIBRARY_SUFFIX})
set(SENTENCEPIECE_INSTALL_LIB_LOCATION
bin/${CMAKE_SHARED_LIBRARY_PREFIX}sentencepiece${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

include(ExternalProject)
Expand All @@ -43,9 +43,8 @@ else()
CMAKE_GENERATOR ${CMAKE_GENERATOR}
INSTALL_COMMAND ${CMAKE_COMMAND} --install <BINARY_DIR> --config ${CMAKE_BUILD_TYPE}
BUILD_BYPRODUCTS <INSTALL_DIR>/${SENTENCEPIECE_INSTALL_LIB_LOCATION}
CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${SP_CMAKE_PLATFORM_OPTIONS})
CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${SP_CMAKE_PLATFORM_OPTIONS})
ExternalProject_Get_Property(sentencepiece_build INSTALL_DIR)

if(UNIX)
Expand All @@ -55,7 +54,7 @@ else()
set_target_properties(
libsentencepiece
PROPERTIES IMPORTED_IMPLIB
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
add_dependencies(libsentencepiece sentencepiece_build)
set_target_properties(libsentencepiece PROPERTIES IMPORTED_LOCATION
Expand Down

0 comments on commit 74daf59

Please sign in to comment.