Skip to content

Commit

Permalink
Handle Linux systems that use /lib64 instead of /lib
Browse files Browse the repository at this point in the history
Use CMAKE_INSTALL_LIBDIR variable to set the correct lib folder to use
for installing libraries so that CMake looks in the right place for the
dependencies when linking
  • Loading branch information
Tabby committed May 27, 2024
1 parent 5227a43 commit 7ef751b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmake/BuildCTranslate2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ else()
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}
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX}
CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CPU_FEATURES_CMAKE_ARGS}
LOG_CONFIGURE ON
Expand All @@ -84,7 +84,7 @@ else()
add_dependencies(cpu_features cpu_features_build)
set_target_properties(
cpu_features PROPERTIES IMPORTED_LOCATION
${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX})
${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX})
set_target_properties(cpu_features PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

# build CTranslate2 from source
Expand All @@ -93,7 +93,7 @@ else()
set(CT2_OPENBLAS_CMAKE_ARGS -DWITH_OPENBLAS=OFF)

set(CT2_CMAKE_PLATFORM_OPTIONS -DBUILD_SHARED_LIBS=OFF -DOPENMP_RUNTIME=NONE -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
set(CT2_LIB_INSTALL_LOCATION lib/${CMAKE_SHARED_LIBRARY_PREFIX}ctranslate2${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CT2_LIB_INSTALL_LOCATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}ctranslate2${CMAKE_STATIC_LIBRARY_SUFFIX})

ExternalProject_Add(
ct2_build
Expand Down
2 changes: 1 addition & 1 deletion cmake/BuildSentencepiece.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ else()
CACHE STRING "URL of sentencepiece repository")

set(SP_CMAKE_OPTIONS -DSPM_ENABLE_SHARED=OFF)
set(SENTENCEPIECE_INSTALL_LIB_LOCATION lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SENTENCEPIECE_INSTALL_LIB_LOCATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})

include(ExternalProject)

Expand Down

0 comments on commit 7ef751b

Please sign in to comment.