[libxml2] Use version in configure.ac for CMake



commit 22f1521122402bee88b58a463af58b5ab865dc3f
Author: Timothy Lyanguzov <timothy lyanguzov sap com>
Date:   Fri Jun 4 09:57:46 2021 +1200

    Use version in configure.ac for CMake
    
    Now CMake script reads version from configure.ac to prevent unsynchronized versions

 CMakeLists.txt | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4c0c794..073869fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,16 @@
 cmake_minimum_required(VERSION 3.15)
 
-project(libxml2 VERSION 2.9.12 LANGUAGES C)
+file(STRINGS "configure.ac" CONFIGURE_AC_LINES)
+foreach(line ${CONFIGURE_AC_LINES})
+       if(line MATCHES [[^m4_define\(\[(MAJOR_VERSION|MINOR_VERSION|MICRO_VERSION)\],[ \t]*([0-9]+)\)$]])
+               set(LIBXML_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+       elseif(line MATCHES "^(LIBXML_MAJOR_VERSION|LIBXML_MINOR_VERSION|LIBXML_MICRO_VERSION)=([0-9]+)$")
+               set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+       endif()
+endforeach()
+set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
+
+project(libxml2 VERSION ${VERSION} LANGUAGES C)
 
 include(CheckCSourceCompiles)
 include(CheckFunctionExists)
@@ -95,11 +105,6 @@ foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_D
        endif()
 endforeach()
 
-set(LIBXML_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
-set(LIBXML_MINOR_VERSION ${PROJECT_VERSION_MINOR})
-set(LIBXML_MICRO_VERSION ${PROJECT_VERSION_PATCH})
-
-set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
 set(LIBXML_VERSION ${LIBXML_MAJOR_VERSION}0${LIBXML_MINOR_VERSION}0${LIBXML_MICRO_VERSION})
 set(LIBXML_VERSION_STRING "${LIBXML_VERSION}")
 set(LIBXML_VERSION_EXTRA "")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]