Skip to content

Commit

Permalink
[VLIB-132] Create and install CMake package configuration files only …
Browse files Browse the repository at this point in the history
…if this feature is supported Mbed-TLS#2
  • Loading branch information
SergeySeroshtan committed Apr 17, 2016
1 parent b265c79 commit f13ed35
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -201,19 +209,26 @@ 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)
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"
Expand All @@ -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)

0 comments on commit f13ed35

Please sign in to comment.