diff --git a/cmake/BuildSentencepiece.cmake b/cmake/BuildSentencepiece.cmake index ce7ce34..f3bf28f 100644 --- a/cmake/BuildSentencepiece.cmake +++ b/cmake/BuildSentencepiece.cmake @@ -20,18 +20,8 @@ else() "https://github.com/google/sentencepiece.git" CACHE STRING "URL of sentencepiece repository") - 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) - endif() - 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}) - endif() + set(SP_CMAKE_OPTIONS -DSPM_ENABLE_SHARED=OFF) + set(SENTENCEPIECE_INSTALL_LIB_LOCATION lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX}) include(ExternalProject) @@ -44,24 +34,12 @@ else() INSTALL_COMMAND ${CMAKE_COMMAND} --install --config ${CMAKE_BUILD_TYPE} BUILD_BYPRODUCTS /${SENTENCEPIECE_INSTALL_LIB_LOCATION} CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${SP_CMAKE_PLATFORM_OPTIONS}) + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${SP_CMAKE_OPTIONS}) ExternalProject_Get_Property(sentencepiece_build INSTALL_DIR) - if(UNIX) - add_library(libsentencepiece STATIC IMPORTED GLOBAL) - else() - add_library(libsentencepiece SHARED IMPORTED GLOBAL) - set_target_properties( - libsentencepiece - PROPERTIES IMPORTED_IMPLIB - ${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 - ${INSTALL_DIR}/${SENTENCEPIECE_INSTALL_LIB_LOCATION}) - - add_library(sentencepiece INTERFACE) - target_link_libraries(sentencepiece INTERFACE ${INSTALL_DIR}/${SENTENCEPIECE_INSTALL_LIB_LOCATION}) + add_library(sentencepiece STATIC IMPORTED GLOBAL) + add_dependencies(sentencepiece sentencepiece_build) + set_target_properties(sentencepiece PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/${SENTENCEPIECE_INSTALL_LIB_LOCATION}) set_target_properties(sentencepiece PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) endif()