From afb2a1587a828bf7cd7ddd87b2e2609a9bb7fab0 Mon Sep 17 00:00:00 2001 From: Eneas U de Queiroz Date: Wed, 6 May 2020 08:59:54 -0300 Subject: [PATCH] Add SOVERSION info to library when using cmake Currently the SOVERSION is different when building with cmake than the value used by autotools. This adds the version information from autotools to cmake. Signed-off-by: Eneas U de Queiroz diff --git a/CMakeLists.txt b/CMakeLists.txt index 29a1417..1c8a090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,19 @@ target_include_directories(onig PUBLIC target_compile_definitions(onig PUBLIC $<$>:ONIG_STATIC>) +if(BUILD_SHARED_LIBS) + # Parse SOVERSION information from LTVERSION in configure.ac + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" LTVERSION REGEX "^LTVERSION *= *\"?[0-9]+:[0-9]+:[0-9]+\"?") + string(REGEX REPLACE "^LTVERSION *= *\"?([0-9]+:[0-9]+:[0-9]+)\"?.*$" "\\1" LTVERSION "${LTVERSION}") + string(REGEX REPLACE "^([0-9]+):([0-9]+):([0-9]+)" "\\1" LTCURRENT ${LTVERSION}) + string(REGEX REPLACE "^([0-9]+):([0-9]+):([0-9]+)" "\\2" LTREVISION ${LTVERSION}) + string(REGEX REPLACE "^([0-9]+):([0-9]+):([0-9]+)" "\\3" LTAGE ${LTVERSION}) + math(EXPR ONIG_SOVERSION "${LTCURRENT} - ${LTAGE}") + set_target_properties(onig PROPERTIES + SOVERSION "${ONIG_SOVERSION}" + VERSION "${ONIG_SOVERSION}.${LTAGE}.${LTREVISION}") +endif() + if(MSVC) target_compile_options(onig PRIVATE #/W4