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 <nathbappai@gmail.com>
This commit is contained in:
Biswapriyo Nath 2022-04-22 20:56:21 +05:30
parent 2f8c2a5fc5
commit 0f2e87bdf5
4 changed files with 10 additions and 4 deletions

View File

@ -23,5 +23,5 @@ endif(INSTALL_MBEDTLS_HEADERS)
install(TARGETS everest install(TARGETS everest
EXPORT MbedTLSTargets EXPORT MbedTLSTargets
DESTINATION ${LIB_INSTALL_DIR} DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

View File

@ -39,6 +39,8 @@ else()
project("mbed TLS" C) project("mbed TLS" C)
endif() endif()
include(GNUInstallDirs)
# Determine if mbed TLS is being built as a subproject using add_subdirectory() # Determine if mbed TLS is being built as a subproject using add_subdirectory()
if(NOT DEFINED MBEDTLS_AS_SUBPROJECT) if(NOT DEFINED MBEDTLS_AS_SUBPROJECT)
set(MBEDTLS_AS_SUBPROJECT ON) set(MBEDTLS_AS_SUBPROJECT ON)
@ -249,8 +251,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
endif(CMAKE_BUILD_TYPE STREQUAL "Coverage") endif(CMAKE_BUILD_TYPE STREQUAL "Coverage")
if(LIB_INSTALL_DIR) if(LIB_INSTALL_DIR)
else() set(CMAKE_INSTALL_LIBDIR "${LIB_INSTALL_DIR}")
set(LIB_INSTALL_DIR lib)
endif() endif()
add_subdirectory(include) add_subdirectory(include)

View File

@ -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.

View File

@ -291,7 +291,7 @@ foreach(target IN LISTS target_libraries)
install( install(
TARGETS ${target} TARGETS ${target}
EXPORT MbedTLSTargets EXPORT MbedTLSTargets
DESTINATION ${LIB_INSTALL_DIR} DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endforeach(target) endforeach(target)