From 5e5056d6abd2d9140b5b842ac245347bf66d5c29 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 22 Apr 2022 20:56:21 +0530 Subject: [PATCH] cmake: Use GnuInstallDirs to customize install directories Replace custom LIB_INSTALL_DIR with standard CMAKE_INSTALL_LIBDIR variable. For backward compatibility, set CMAKE_INSTALL_LIBDIR if LIB_INSTALL_DIR is set. Signed-off-by: Biswapriyo Nath --- CMakeLists.txt | 5 +++-- ChangeLog.d/cmake_use_GnuInstallDirs.txt | 5 +++++ library/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 ChangeLog.d/cmake_use_GnuInstallDirs.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c6bbb753..844491778 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ else() project("Mbed TLS" C) endif() +include(GNUInstallDirs) + # Set the project root directory. set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -259,8 +261,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Coverage") endif(CMAKE_BUILD_TYPE STREQUAL "Coverage") if(LIB_INSTALL_DIR) -else() - set(LIB_INSTALL_DIR lib) + set(CMAKE_INSTALL_LIBDIR "${LIB_INSTALL_DIR}") endif() if(ENABLE_ZLIB_SUPPORT) diff --git a/ChangeLog.d/cmake_use_GnuInstallDirs.txt b/ChangeLog.d/cmake_use_GnuInstallDirs.txt new file mode 100644 index 000000000..d8487555d --- /dev/null +++ b/ChangeLog.d/cmake_use_GnuInstallDirs.txt @@ -0,0 +1,5 @@ +Changes + * cmake: Use GnuInstallDirs to customize install directories + Replace custom LIB_INSTALL_DIR variable with standard CMAKE_INSTALL_LIBDIR + variable. For backward compatibility, set CMAKE_INSTALL_LIBDIR if + LIB_INSTALL_DIR is set. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 1b2980dbc..798f42f71 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -239,7 +239,7 @@ foreach(target IN LISTS target_libraries) PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}") endif() install(TARGETS ${target} - DESTINATION ${LIB_INSTALL_DIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) endforeach(target)