From 7cabadd9035013816dfbc951c74cf3f2709c1489 Mon Sep 17 00:00:00 2001 From: Xorg Date: Sat, 22 Oct 2022 21:16:44 +0200 Subject: [PATCH] CMake: create shared libraries with correct SO name Fix #174 --- CMakeLists.txt | 4 +++- bump_version.sh | 17 +++++++++++++---- libcpuid/CMakeLists.txt | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5425aa..7e6b3bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.13) set(VERSION "0.6.0") -set(SOVERSION 16) +set(LIBCPUID_CURRENT 16) +set(LIBCPUID_AGE 0) +set(LIBCPUID_REVISION 0) project( cpuid LANGUAGES C CXX ASM_MASM diff --git a/bump_version.sh b/bump_version.sh index 594ac22..6da40ab 100755 --- a/bump_version.sh +++ b/bump_version.sh @@ -16,13 +16,22 @@ if ! [[ "$SO_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then exit 1 fi +IFS='.' read -a so_version_array <<< "$SO_VERSION" +LIBCPUID_CURRENT="${so_version_array[0]}" +LIBCPUID_AGE="${so_version_array[1]}" +LIBCPUID_REVISION="${so_version_array[2]}" +echo "$DATE: bumping libcpuid version from $OLD_VERSION to $NEW_VERSION" +echo "LIBCPUID_CURRENT=$LIBCPUID_CURRENT LIBCPUID_AGE=$LIBCPUID_AGE LIBCPUID_REVISION=$LIBCPUID_REVISION" + echo -e "\nVersion $NEW_VERSION ($DATE):" >> "$GIT_DIR/ChangeLog" sed -i "s|\[$OLD_VERSION\]|\[$NEW_VERSION\]|" "$GIT_DIR/configure.ac" -sed -i "s|LIBCPUID_CURRENT=.*|dnl $(echo $SO_VERSION | tr . :) Version $NEW_VERSION:\nLIBCPUID_CURRENT=$(echo $SO_VERSION | cut -d. -f1)|" "$GIT_DIR/configure.ac" -sed -i "s|LIBCPUID_AGE=.*|LIBCPUID_AGE=$(echo $SO_VERSION | cut -d. -f2)|" "$GIT_DIR/configure.ac" -sed -i "s|LIBCPUID_REVISION=.*|LIBCPUID_REVISION=$(echo $SO_VERSION | cut -d. -f3)|" "$GIT_DIR/configure.ac" +sed -i "s|LIBCPUID_CURRENT=.*|dnl $(echo $SO_VERSION | tr . :) Version $NEW_VERSION:\nLIBCPUID_CURRENT=$LIBCPUID_CURRENT|" "$GIT_DIR/configure.ac" +sed -i "s|LIBCPUID_AGE=.*|LIBCPUID_AGE=$LIBCPUID_AGE|" "$GIT_DIR/configure.ac" +sed -i "s|LIBCPUID_REVISION=.*|LIBCPUID_REVISION=$LIBCPUID_REVISION|" "$GIT_DIR/configure.ac" sed -i "s|VERSION \"$OLD_VERSION\"|VERSION \"$NEW_VERSION\"|" "$GIT_DIR/CMakeLists.txt" -sed -i "s|set(SOVERSION .*)|set(SOVERSION $(echo $SO_VERSION | cut -d. -f1))|" "$GIT_DIR/CMakeLists.txt" +sed -i "s|set(LIBCPUID_CURRENT .*)|set(LIBCPUID_CURRENT $LIBCPUID_CURRENT)|" "$GIT_DIR/CMakeLists.txt" +sed -i "s|set(LIBCPUID_AGE .*)|set(LIBCPUID_AGE $LIBCPUID_AGE)|" "$GIT_DIR/CMakeLists.txt" +sed -i "s|set(LIBCPUID_REVISION .*)|set(LIBCPUID_REVISION $LIBCPUID_REVISION)|" "$GIT_DIR/CMakeLists.txt" sed -i "s|$OLD_VERSION|$NEW_VERSION|g" "$GIT_DIR/libcpuid/"{Makefile.x64,Makefile.x86,libcpuid.dsp,libcpuid_vc10.vcxproj,libcpuid_vc71.vcproj} sed -i "s|\\\version $OLD_VERSION|\\\version $NEW_VERSION|" "$GIT_DIR/libcpuid/libcpuid.h" diff --git a/libcpuid/CMakeLists.txt b/libcpuid/CMakeLists.txt index a80284d..d285f8b 100644 --- a/libcpuid/CMakeLists.txt +++ b/libcpuid/CMakeLists.txt @@ -23,8 +23,8 @@ set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) target_include_directories(cpuid SYSTEM PUBLIC $) target_compile_definitions(cpuid PRIVATE VERSION="${PROJECT_VERSION}") -set_target_properties(cpuid PROPERTIES VERSION ${PROJECT_VERSION}) -set_target_properties(cpuid PROPERTIES SOVERSION ${SOVERSION}) +set_target_properties(cpuid PROPERTIES VERSION "${LIBCPUID_CURRENT}.${LIBCPUID_AGE}.${LIBCPUID_REVISION}") +set_target_properties(cpuid PROPERTIES SOVERSION "${LIBCPUID_CURRENT}") set_target_properties(cpuid PROPERTIES PUBLIC_HEADER "libcpuid.h;libcpuid_types.h;libcpuid_constants.h") # Documentation