From 879cba1a67d01317422870ff736057ca2d23247f Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Thu, 18 Sep 2025 16:55:11 +0200 Subject: [PATCH] cmake: Introduce version and soversion variables Signed-off-by: Ronald Cron --- CMakeLists.txt | 9 +++++++-- library/CMakeLists.txt | 4 ++-- scripts/bump_version.sh | 24 ++++++++++-------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ddc2738d..659fd50885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,15 +37,20 @@ cmake_policy(SET CMP0011 NEW) # is deprecated and will be removed in future versions. cmake_policy(SET CMP0012 NEW) +set(MBEDTLS_VERSION 4.0.0) +set(MBEDTLS_CRYPTO_SOVERSION 17) +set(MBEDTLS_X509_SOVERSION 8) +set(MBEDTLS_TLS_SOVERSION 22) + if(TEST_CPP) project("Mbed TLS" LANGUAGES C CXX - VERSION 4.0.0 + VERSION ${MBEDTLS_VERSION} ) else() project("Mbed TLS" LANGUAGES C - VERSION 4.0.0 + VERSION ${MBEDTLS_VERSION} ) endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4f9da39f54..59e175bb0a 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -208,13 +208,13 @@ if(USE_SHARED_MBEDTLS_LIBRARY) add_library(${mbedx509_target} SHARED ${src_x509}) set_base_compile_options(${mbedx509_target}) target_compile_options(${mbedx509_target} PRIVATE ${LIBS_C_FLAGS}) - set_target_properties(${mbedx509_target} PROPERTIES VERSION 4.0.0 SOVERSION 8) + set_target_properties(${mbedx509_target} PROPERTIES VERSION ${MBEDTLS_VERSION} SOVERSION ${MBEDTLS_X509_SOVERSION}) target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${tfpsacrypto_target}) add_library(${mbedtls_target} SHARED ${src_tls}) set_base_compile_options(${mbedtls_target}) target_compile_options(${mbedtls_target} PRIVATE ${LIBS_C_FLAGS}) - set_target_properties(${mbedtls_target} PROPERTIES VERSION 4.0.0 SOVERSION 21) + set_target_properties(${mbedtls_target} PROPERTIES VERSION ${MBEDTLS_VERSION} SOVERSION ${MBEDTLS_TLS_SOVERSION}) target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) if(GEN_FILES) diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 86ed74eada..a15bb9649b 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -70,18 +70,14 @@ then fi [ $VERBOSE ] && echo "Bumping VERSION in CMakeLists.txt" -sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < CMakeLists.txt > tmp +sed -e "s/(MBEDTLS_VERSION [0-9.]\{1,\})/(MBEDTLS_VERSION $VERSION)/g" < CMakeLists.txt > tmp mv tmp CMakeLists.txt -[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt" -sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp -mv tmp library/CMakeLists.txt - if [ "X" != "X$SO_CRYPTO" ]; then - [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt" - sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp - mv tmp library/CMakeLists.txt + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in CMakeLists.txt" + sed -e "s/(MBEDTLS_CRYPTO_SOVERSION [0-9]\{1,\})/(MBEDTLS_CRYPTO_SOVERSION $SO_CRYPTO)/g" < CMakeLists.txt > tmp + mv tmp CMakeLists.txt [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile" sed -e "s/SOEXT_CRYPTO?=so.[0-9]\{1,\}/SOEXT_CRYPTO?=so.$SO_CRYPTO/g" < library/Makefile > tmp @@ -90,9 +86,9 @@ fi if [ "X" != "X$SO_X509" ]; then - [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt" - sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp - mv tmp library/CMakeLists.txt + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in CMakeLists.txt" + sed -e "s/(MBEDTLS_X509_SOVERSION [0-9]\{1,\})/(MBEDTLS_X509_SOVERSION $SO_X509)/g" < CMakeLists.txt > tmp + mv tmp CMakeLists.txt [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile" sed -e "s/SOEXT_X509?=so.[0-9]\{1,\}/SOEXT_X509?=so.$SO_X509/g" < library/Makefile > tmp @@ -101,9 +97,9 @@ fi if [ "X" != "X$SO_TLS" ]; then - [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt" - sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp - mv tmp library/CMakeLists.txt + [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in CMakeLists.txt" + sed -e "s/(MBEDTLS_TLS_SOVERSION [0-9]\{1,\})/(MBEDTLS_TLS_SOVERSION $SO_TLS)/g" < CMakeLists.txt > tmp + mv tmp CMakeLists.txt [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile" sed -e "s/SOEXT_TLS?=so.[0-9]\{1,\}/SOEXT_TLS?=so.$SO_TLS/g" < library/Makefile > tmp