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
  • Loading branch information
SergeySeroshtan committed Apr 17, 2016
1 parent 93ab990 commit b265c79
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,25 @@ elseif(USE_STATIC_MBEDTLS_LIBRARY)
set(ed25519_static_target "ed25519")
endif()

# Create CMake configuration files
include(CMakePackageConfigHelpers)

## Define names for configuration files
set (generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set (version_config "${generated_dir}/mbedtls-config-version.cmake")
set (project_config "${generated_dir}/mbedtls-config.cmake")
set (targets_export_name "mbedtls-targets")

## Write 'mbedtls-config-version.cmake' file
write_basic_package_version_file(
${version_config} VERSION 2.2.1 COMPATIBILITY SameMajorVersion)

## Configure 'mbedtls-config.cmake' file
configure_package_config_file(
"cmake/config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${LIB_INSTALL_DIR}/cmake")
if(CMAKE_VERSION VERSION_GREATER 2.8.7)
## Define names for configuration files
set (generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set (version_config "${generated_dir}/mbedtls-config-version.cmake")
set (project_config "${generated_dir}/mbedtls-config.cmake")

# Create CMake configuration files
include(CMakePackageConfigHelpers)

## Write 'mbedtls-config-version.cmake' file
write_basic_package_version_file(
${version_config} VERSION 2.2.1 COMPATIBILITY SameMajorVersion)

## Configure 'mbedtls-config.cmake' file
configure_package_config_file(
"cmake/config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${LIB_INSTALL_DIR}/cmake")
endif(CMAKE_VERSION VERSION_GREATER 2.8.7)

# Create and install targets
if(USE_STATIC_MBEDTLS_LIBRARY)
Expand All @@ -177,7 +178,7 @@ if(USE_STATIC_MBEDTLS_LIBRARY)

install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target}
${ed25519_static_target}
EXPORT "${targets_export_name}"
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")
Expand All @@ -201,7 +202,7 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
target_link_libraries(mbedtls ${libs} mbedx509)

install(TARGETS mbedtls mbedx509 mbedcrypto ed25519
EXPORT "${targets_export_name}"
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")
Expand All @@ -212,13 +213,14 @@ if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY)
add_dependencies(lib mbedcrypto_static mbedx509_static mbedtls_static ed25519_static)
endif()

# Install configuration files

install(FILES "${project_config}" "${version_config}"
DESTINATION "${LIB_INSTALL_DIR}/cmake/MbedTLS"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

install(EXPORT ${targets_export_name}
NAMESPACE "mbedtls::"
DESTINATION "${LIB_INSTALL_DIR}/cmake/MbedTLS"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
if(CMAKE_VERSION VERSION_GREATER 2.8.7)
# Install configuration files
install(FILES "${project_config}" "${version_config}"
DESTINATION "${LIB_INSTALL_DIR}/cmake/MbedTLS"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

install(EXPORT "mbedtls-targets"
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)

0 comments on commit b265c79

Please sign in to comment.