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 "")