From f13ed355f444d4217a6ba293bce54ac66d3bf2b8 Mon Sep 17 00:00:00 2001 From: Sergey Seroshtan Date: Sun, 17 Apr 2016 22:43:09 +0300 Subject: [PATCH] [VLIB-132] Create and install CMake package configuration files only if this feature is supported #2 --- library/CMakeLists.txt | 45 ++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 74d4b18b0ac3..7d75ac02b08a 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -138,7 +138,7 @@ elseif(USE_STATIC_MBEDTLS_LIBRARY) set(ed25519_static_target "ed25519") endif() -if(CMAKE_VERSION VERSION_GREATER 2.8.7) +if(NOT CMAKE_VERSION VERSION_LESS 3.0) ## Define names for configuration files set (generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set (version_config "${generated_dir}/mbedtls-config-version.cmake") @@ -156,7 +156,7 @@ if(CMAKE_VERSION VERSION_GREATER 2.8.7) "cmake/config.cmake.in" "${project_config}" INSTALL_DESTINATION "${LIB_INSTALL_DIR}/cmake") -endif(CMAKE_VERSION VERSION_GREATER 2.8.7) +endif(NOT CMAKE_VERSION VERSION_LESS 3.0) # Create and install targets if(USE_STATIC_MBEDTLS_LIBRARY) @@ -176,12 +176,20 @@ if(USE_STATIC_MBEDTLS_LIBRARY) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) - install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} - ${ed25519_static_target} - EXPORT "mbedtls-targets" - DESTINATION "${LIB_INSTALL_DIR}" - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - INCLUDES DESTINATION "include") + if(CMAKE_VERSION VERSION_LESS 3.0) + install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} + ${ed25519_static_target} + DESTINATION "${LIB_INSTALL_DIR}" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + else(CMAKE_VERSION VERSION_LESS 3.0) + install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} + ${ed25519_static_target} + EXPORT "mbedtls-targets" + DESTINATION "${LIB_INSTALL_DIR}" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + INCLUDES DESTINATION "include") + endif (CMAKE_VERSION VERSION_LESS 3.0) + endif(USE_STATIC_MBEDTLS_LIBRARY) if(USE_SHARED_MBEDTLS_LIBRARY) @@ -201,11 +209,18 @@ if(USE_SHARED_MBEDTLS_LIBRARY) set_target_properties(mbedtls PROPERTIES VERSION 2.2.1 SOVERSION 10) target_link_libraries(mbedtls ${libs} mbedx509) - install(TARGETS mbedtls mbedx509 mbedcrypto ed25519 - EXPORT "mbedtls-targets" - DESTINATION "${LIB_INSTALL_DIR}" - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - INCLUDES DESTINATION "include") + if(CMAKE_VERSION VERSION_LESS 3.0) + install(TARGETS mbedtls mbedx509 mbedcrypto ed25519 + DESTINATION "${LIB_INSTALL_DIR}" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + else(CMAKE_VERSION VERSION_LESS 3.0) + install(TARGETS mbedtls mbedx509 mbedcrypto ed25519 + EXPORT "mbedtls-targets" + DESTINATION "${LIB_INSTALL_DIR}" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + INCLUDES DESTINATION "include") + endif (CMAKE_VERSION VERSION_LESS 3.0) + endif(USE_SHARED_MBEDTLS_LIBRARY) add_custom_target(lib DEPENDS mbedcrypto mbedx509 mbedtls ed25519) @@ -213,7 +228,7 @@ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static ed25519_static) endif() -if(CMAKE_VERSION VERSION_GREATER 2.8.7) +if(NOT CMAKE_VERSION VERSION_LESS 3.0) # Install configuration files install(FILES "${project_config}" "${version_config}" DESTINATION "${LIB_INSTALL_DIR}/cmake/MbedTLS" @@ -223,4 +238,4 @@ if(CMAKE_VERSION VERSION_GREATER 2.8.7) NAMESPACE "mbedtls::" DESTINATION "${LIB_INSTALL_DIR}/cmake/MbedTLS" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) -endif(CMAKE_VERSION VERSION_GREATER 2.8.7) +endif(NOT CMAKE_VERSION VERSION_LESS 3.0)