From 0f2e87bdf534a967937882e7381e067d9b1cb135 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 22 Apr 2022 20:56:21 +0530 Subject: [PATCH 1/2] 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 --- 3rdparty/everest/CMakeLists.txt | 2 +- CMakeLists.txt | 5 +++-- ChangeLog.d/cmake_use_GnuInstallDirs.txt | 5 +++++ library/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 ChangeLog.d/cmake_use_GnuInstallDirs.txt diff --git a/3rdparty/everest/CMakeLists.txt b/3rdparty/everest/CMakeLists.txt index ff9da7af7d..4ad367e17a 100644 --- a/3rdparty/everest/CMakeLists.txt +++ b/3rdparty/everest/CMakeLists.txt @@ -23,5 +23,5 @@ endif(INSTALL_MBEDTLS_HEADERS) install(TARGETS everest EXPORT MbedTLSTargets - DESTINATION ${LIB_INSTALL_DIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fccd3d1bd..11ca1c9893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,8 @@ else() project("mbed TLS" C) endif() +include(GNUInstallDirs) + # Determine if mbed TLS is being built as a subproject using add_subdirectory() if(NOT DEFINED MBEDTLS_AS_SUBPROJECT) set(MBEDTLS_AS_SUBPROJECT ON) @@ -249,8 +251,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() add_subdirectory(include) diff --git a/ChangeLog.d/cmake_use_GnuInstallDirs.txt b/ChangeLog.d/cmake_use_GnuInstallDirs.txt new file mode 100644 index 0000000000..d8487555d1 --- /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 6bb2ad38ce..d8d28408f2 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -291,7 +291,7 @@ foreach(target IN LISTS target_libraries) install( TARGETS ${target} EXPORT MbedTLSTargets - DESTINATION ${LIB_INSTALL_DIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) endforeach(target) From d7e0ee42b8ba9e275538bf10c870550c29b3fe14 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 22 Apr 2022 20:59:50 +0530 Subject: [PATCH 2/2] cmake: Fix runtime library install location in mingw This install DLLs in bin directory instead of lib. Signed-off-by: Biswapriyo Nath --- ChangeLog.d/cmake_fix_dll_install.txt | 3 +++ library/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 ChangeLog.d/cmake_fix_dll_install.txt diff --git a/ChangeLog.d/cmake_fix_dll_install.txt b/ChangeLog.d/cmake_fix_dll_install.txt new file mode 100644 index 0000000000..df51c650bb --- /dev/null +++ b/ChangeLog.d/cmake_fix_dll_install.txt @@ -0,0 +1,3 @@ +Changes + * cmake: Fix runtime library install location in mingw + This install DLLs in bin directory instead of lib. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index d8d28408f2..a726e11fff 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -291,7 +291,9 @@ foreach(target IN LISTS target_libraries) install( TARGETS ${target} EXPORT MbedTLSTargets - DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) endforeach(target)