You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.5 KiB

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