From 09ec4ff9c14d1859f57efcb1303d666c8232d7a9 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 20 May 2021 15:29:21 +0200 Subject: cmake/autotools: Use AC_CHECK_SIZEOF to fix 32bit support --- .github/workflows/data/expat_config_h_in__expected.txt | 1 + expat/cmake/autotools/expat-config-version.cmake.in | 6 +++--- expat/configure.ac | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/data/expat_config_h_in__expected.txt b/.github/workflows/data/expat_config_h_in__expected.txt index 3c23e8fc..56f66137 100644 --- a/.github/workflows/data/expat_config_h_in__expected.txt +++ b/.github/workflows/data/expat_config_h_in__expected.txt @@ -29,6 +29,7 @@ PACKAGE_STRING PACKAGE_TARNAME PACKAGE_URL PACKAGE_VERSION +SIZEOF_VOID_P size_t STDC_HEADERS VERSION diff --git a/expat/cmake/autotools/expat-config-version.cmake.in b/expat/cmake/autotools/expat-config-version.cmake.in index 798d861d..5b296752 100644 --- a/expat/cmake/autotools/expat-config-version.cmake.in +++ b/expat/cmake/autotools/expat-config-version.cmake.in @@ -55,13 +55,13 @@ if("FALSE") endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@ac_cv_sizeof_void_p@" STREQUAL "") return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") - math(EXPR installedBits "8 * 8") +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@ac_cv_sizeof_void_p@") + math(EXPR installedBits "@ac_cv_sizeof_void_p@ * 8") set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/expat/configure.ac b/expat/configure.ac index 7d60a2c2..6ba69a2e 100644 --- a/expat/configure.ac +++ b/expat/configure.ac @@ -372,6 +372,7 @@ LIBDIR_BASENAME="$(basename "${libdir}")" SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")" SO_MINOR="${LIBAGE}" SO_PATCH="${LIBREVISION}" +AC_CHECK_SIZEOF([void *]) # sets ac_cv_sizeof_void_p AC_SUBST([EXPAT_ATTR_INFO]) AC_SUBST([EXPAT_DTD]) AC_SUBST([EXPAT_LARGE_SIZE]) @@ -384,6 +385,7 @@ AC_SUBST([LIBDIR_BASENAME]) AC_SUBST([SO_MAJOR]) AC_SUBST([SO_MINOR]) AC_SUBST([SO_PATCH]) +AC_SUBST([ac_cv_sizeof_void_p]) dnl write the Automake flags we set -- cgit v1.2.1 From 43142f0babc617123bccd2f516223c90ca9e6dbc Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 20 May 2021 16:07:03 +0200 Subject: cmake/autotools: Fix generated expat-noconfig.cmake for macOS and MinGW --- expat/Makefile.am | 3 +++ expat/cmake/autotools/expat-noconfig.cmake.in | 19 ------------------- expat/cmake/autotools/expat-noconfig__linux.cmake.in | 19 +++++++++++++++++++ expat/cmake/autotools/expat-noconfig__macos.cmake.in | 19 +++++++++++++++++++ .../cmake/autotools/expat-noconfig__windows.cmake.in | 19 +++++++++++++++++++ expat/configure.ac | 6 +++++- 6 files changed, 65 insertions(+), 20 deletions(-) delete mode 100644 expat/cmake/autotools/expat-noconfig.cmake.in create mode 100644 expat/cmake/autotools/expat-noconfig__linux.cmake.in create mode 100644 expat/cmake/autotools/expat-noconfig__macos.cmake.in create mode 100644 expat/cmake/autotools/expat-noconfig__windows.cmake.in diff --git a/expat/Makefile.am b/expat/Makefile.am index 49d157aa..6847d083 100644 --- a/expat/Makefile.am +++ b/expat/Makefile.am @@ -66,6 +66,9 @@ cmakedir = $(libdir)/cmake/expat-@PACKAGE_VERSION@ _EXTRA_DIST_CMAKE = \ + cmake/autotools/expat-noconfig__linux.cmake.in \ + cmake/autotools/expat-noconfig__macos.cmake.in \ + cmake/autotools/expat-noconfig__windows.cmake.in \ cmake/autotools/expat-package-init.cmake \ cmake/mingw-toolchain.cmake \ \ diff --git a/expat/cmake/autotools/expat-noconfig.cmake.in b/expat/cmake/autotools/expat-noconfig.cmake.in deleted file mode 100644 index 39595048..00000000 --- a/expat/cmake/autotools/expat-noconfig.cmake.in +++ /dev/null @@ -1,19 +0,0 @@ -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Import target "expat::expat" for configuration "" -set_property(TARGET expat::expat APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) -set_target_properties(expat::expat PROPERTIES - IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.so.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@" - IMPORTED_SONAME_NOCONFIG "libexpat.so.@SO_MAJOR@" - ) - -list(APPEND _IMPORT_CHECK_TARGETS expat::expat ) -list(APPEND _IMPORT_CHECK_FILES_FOR_expat::expat "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.so.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@" ) - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) diff --git a/expat/cmake/autotools/expat-noconfig__linux.cmake.in b/expat/cmake/autotools/expat-noconfig__linux.cmake.in new file mode 100644 index 00000000..39595048 --- /dev/null +++ b/expat/cmake/autotools/expat-noconfig__linux.cmake.in @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "expat::expat" for configuration "" +set_property(TARGET expat::expat APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(expat::expat PROPERTIES + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.so.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@" + IMPORTED_SONAME_NOCONFIG "libexpat.so.@SO_MAJOR@" + ) + +list(APPEND _IMPORT_CHECK_TARGETS expat::expat ) +list(APPEND _IMPORT_CHECK_FILES_FOR_expat::expat "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.so.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/expat/cmake/autotools/expat-noconfig__macos.cmake.in b/expat/cmake/autotools/expat-noconfig__macos.cmake.in new file mode 100644 index 00000000..b6b1016c --- /dev/null +++ b/expat/cmake/autotools/expat-noconfig__macos.cmake.in @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "expat::expat" for configuration "" +set_property(TARGET expat::expat APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(expat::expat PROPERTIES + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@.dylib" + IMPORTED_SONAME_NOCONFIG "@rpath/libexpat.@SO_MAJOR@.dylib" + ) + +list(APPEND _IMPORT_CHECK_TARGETS expat::expat ) +list(APPEND _IMPORT_CHECK_FILES_FOR_expat::expat "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.@SO_MAJOR@.@SO_MINOR@.@SO_PATCH@.dylib" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/expat/cmake/autotools/expat-noconfig__windows.cmake.in b/expat/cmake/autotools/expat-noconfig__windows.cmake.in new file mode 100644 index 00000000..66b2f5cb --- /dev/null +++ b/expat/cmake/autotools/expat-noconfig__windows.cmake.in @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "expat::expat" for configuration "" +set_property(TARGET expat::expat APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(expat::expat PROPERTIES + IMPORTED_IMPLIB_NOCONFIG "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.dll.a" + IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/bin/libexpat-@SO_MAJOR@.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS expat::expat ) +list(APPEND _IMPORT_CHECK_FILES_FOR_expat::expat "${_IMPORT_PREFIX}/@LIBDIR_BASENAME@/libexpat.dll.a" "${_IMPORT_PREFIX}/bin/libexpat-@SO_MAJOR@.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/expat/configure.ac b/expat/configure.ac index 6ba69a2e..84319d64 100644 --- a/expat/configure.ac +++ b/expat/configure.ac @@ -397,11 +397,15 @@ AC_SUBST([AM_LDFLAGS]) dnl updating _EXPAT_OUTPUT_NAME variable to effect the package name in expat.pc file (issue #361) AC_SUBST(_EXPAT_OUTPUT_NAME, ["$PACKAGE_NAME"]) +AS_CASE("${host_os}", + [darwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__macos.cmake.in], + [mingw*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__windows.cmake.in], + [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__linux.cmake.in]) AC_CONFIG_FILES([Makefile] [expat.pc] [cmake/expat-config.cmake] [cmake/autotools/expat-config-version.cmake] - [cmake/autotools/expat-noconfig.cmake] + [cmake/autotools/expat-noconfig.cmake:${CMAKE_NOCONFIG_SOURCE}] [doc/Makefile] [examples/Makefile] [lib/Makefile] -- cgit v1.2.1 From 0b8dacdcce89386a9ebda8a192ecd0b78dee16df Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 20 May 2021 23:32:29 +0200 Subject: autotools-cmake.yml: Cover macOS and MinGW --- .github/workflows/autotools-cmake.yml | 65 +++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/.github/workflows/autotools-cmake.yml b/.github/workflows/autotools-cmake.yml index 2dc1a5b8..12d5ad62 100644 --- a/.github/workflows/autotools-cmake.yml +++ b/.github/workflows/autotools-cmake.yml @@ -38,15 +38,43 @@ on: jobs: checks: name: Ensure that GNU Autotools and CMake build systems agree - runs-on: ubuntu-20.04 + strategy: + matrix: + include: + - os: macos-10.15 + configure_args: + cmake_args: + - os: ubuntu-20.04 + configure_args: + cmake_args: + - os: ubuntu-20.04 + configure_args: --host=i686-w64-mingw32 + cmake_args: -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-toolchain.cmake + defaults: + run: + shell: bash + runs-on: "${{ matrix.os }}" steps: - uses: actions/checkout@v2.3.4 - - name: Install build dependencies + - name: (Linux) Install build dependencies + if: "${{ runner.os == 'Linux' }}" run: |- sudo apt-get install --yes --no-install-recommends -V \ cmake \ docbook2x \ + lzip \ + mingw-w64 + + - name: (macOS) Install build dependencies + if: "${{ runner.os == 'macOS' }}" + run: | + brew install \ + autoconf \ + automake \ + cmake \ + docbook2x \ + libtool \ lzip - name: Produce and extract a release archive @@ -64,8 +92,11 @@ jobs: cd expat/expat-*.*.*/ mkdir build_autotools cd build_autotools - ../configure --libdir='${exec_prefix}/lib123' + ../configure \ + --libdir='${exec_prefix}/lib123' \ + ${{matrix.configure_args}} make install DESTDIR="${PWD}"/ROOT + find ROOT | sort | xargs ls -ld - name: Build and install using CMake run: | @@ -73,24 +104,46 @@ jobs: cd expat/expat-*.*.*/ mkdir build_cmake cd build_cmake - cmake -DCMAKE_INSTALL_LIBDIR=lib123 .. + cmake \ + -DCMAKE_INSTALL_LIBDIR=lib123 \ + ${{matrix.cmake_args}} \ + .. make install DESTDIR="${PWD}"/ROOT + find ROOT | sort | xargs ls -ld - name: Check for identical CMake files from both build systems run: | set -x cd expat/expat-*.*.*/ + + if [[ "${{ matrix.configure_args }}" == *mingw* ]]; then + # There is one known difference between Autotools and CMake for MinGW: + # Autotools: usr/local/bin/libexpat-.dll + # CMake: usr/local/bin/libexpat.dll + # We patch the Autotools side in line here to get the differ below to empty + mv build_autotools/ROOT/usr/local/bin/libexpat{-*,}.dll + ( cd build_autotools/ROOT/usr/local/lib*/cmake/expat-*/ \ + && sed 's,libexpat-[0-9]\+\.dll,libexpat.dll,g' expat-noconfig.cmake > expat-noconfig-patched.cmake \ + && ! diff -u0 expat-noconfig{,-patched}.cmake \ + && mv expat-noconfig{-patched,}.cmake ) + fi + diff \ --recursive \ --unified \ --exclude=xmlwf \ + --exclude=xmlwf.exe \ --exclude=libexpat.a \ + --exclude=libexpat.dll \ + --exclude=libexpat.dll.a \ --exclude=libexpat.la \ - --exclude='*.so*' \ + --exclude=libexpat.so\* \ + --exclude=libexpat.\*dylib \ --exclude=expat_config.h \ build_{autotools,cmake}/ROOT - - name: Check for identical exported symbols from both build systems + - name: (Linux except MinGW) Check for identical exported symbols from both build systems + if: "${{ runner.os == 'Linux' && ! contains(matrix.configure_args, 'mingw') }}" run: | list_shared_library_symbols_sh="${GITHUB_WORKSPACE}"/.github/workflows/scripts/list-shared-library-symbols.sh exported_symbols_txt="${GITHUB_WORKSPACE}"/.github/workflows/data/exported-symbols.txt -- cgit v1.2.1 From 192af39be0458273f0a8ac407e4a848d52f484d6 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 20 May 2021 16:02:02 +0200 Subject: Changes: Document Autotools CMake file fixes --- expat/Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/expat/Changes b/expat/Changes index 60912e51..2870961f 100644 --- a/expat/Changes +++ b/expat/Changes @@ -19,6 +19,9 @@ Release X.X.X XXX XXXXX XX XXXX #332 #470 For (non-default) compilation with -DEXPAT_MIN_SIZE=ON (CMake) or CPPFLAGS=-DXML_MIN_SIZE (GNU Autotools): Fix segfault for UTF-16 payloads containing CDATA sections. + #485 #486 Autotools: Fix generated CMake files for non-64bit and + non-Linux platforms (e.g. macOS and MinGW in particular) + that were introduced with release 2.3.0 New features: #34 #466 #484 Add two new API functions to further tighten billion laughs -- cgit v1.2.1