From f00c5857f9c0f9ff3f550d7f35a921c4ae7eadad Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 7 Mar 2022 03:04:13 +0100 Subject: [PATCH] CMake: Enforce library versioning compatible with GNU Libtool for macOS --- expat/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 665a5d88..ce69a278 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -422,6 +422,18 @@ if(NOT WIN32) set_property(TARGET expat PROPERTY VERSION ${LIBCURRENT_MINUS_AGE}.${LIBAGE}.${LIBREVISION}) set_property(TARGET expat PROPERTY SOVERSION ${LIBCURRENT_MINUS_AGE}) set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME}) + + if(APPLE) + if(NOT CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + message(FATAL_ERROR "Expat requires CMake >=3.17 on platform \"APPLE\".") + endif() + + # NOTE: This intends to talk CMake into compatiblity with GNU Libtool + math(EXPR _EXPAT_MACHO_COMPATIBILITY_VERSION "${LIBCURRENT} + 1") + set(_EXPAT_MACHO_CURRENT_VERSION "${_EXPAT_MACHO_COMPATIBILITY_VERSION}.${LIBREVISION}") + set_property(TARGET expat PROPERTY MACHO_COMPATIBILITY_VERSION ${_EXPAT_MACHO_COMPATIBILITY_VERSION}) + set_property(TARGET expat PROPERTY MACHO_CURRENT_VERSION ${_EXPAT_MACHO_CURRENT_VERSION}) + endif() endif() if(WIN32 AND NOT MINGW) # NOTE: This avoids a name collision with Expat.dll of Perl's XML::Parser::Expat