From 7ef751b21b97a53724effd12681ce4aa49122ed4 Mon Sep 17 00:00:00 2001 From: Tabby Cromarty Date: Sun, 26 May 2024 19:30:22 +0100 Subject: [PATCH] Handle Linux systems that use /lib64 instead of /lib 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 --- cmake/BuildCTranslate2.cmake | 6 +++--- cmake/BuildSentencepiece.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/BuildCTranslate2.cmake b/cmake/BuildCTranslate2.cmake index 9117d65..59df248 100644 --- a/cmake/BuildCTranslate2.cmake +++ b/cmake/BuildCTranslate2.cmake @@ -72,7 +72,7 @@ else() BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${CMAKE_BUILD_TYPE} CMAKE_GENERATOR ${CMAKE_GENERATOR} INSTALL_COMMAND ${CMAKE_COMMAND} --install --config ${CMAKE_BUILD_TYPE} - BUILD_BYPRODUCTS /lib/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS /${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}cpu_features${CMAKE_STATIC_LIBRARY_SUFFIX} CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CPU_FEATURES_CMAKE_ARGS} LOG_CONFIGURE ON @@ -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 @@ -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 diff --git a/cmake/BuildSentencepiece.cmake b/cmake/BuildSentencepiece.cmake index 024283e..d27a173 100644 --- a/cmake/BuildSentencepiece.cmake +++ b/cmake/BuildSentencepiece.cmake @@ -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)