Use version in configure.ac for CMake

Now CMake script reads version from configure.ac to prevent unsynchronized versions
This commit is contained in:
Timothy Lyanguzov 2021-06-04 09:57:46 +12:00 committed by Nick Wellnhofer
parent 92d9ab4c28
commit 22f1521122

View File

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