summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2021-09-08 17:57:00 +0200
committerSebastian Pipping <sebastian@pipping.org>2021-09-10 17:20:08 +0200
commit6ae5333645afd486c08d078246077cf0e721a5e1 (patch)
treebdd87cde5f36a0ae6d20cbb8af068eca04dd0dd0
parent634cc999e0dd43d5c11a4abe9fb5e42241f30473 (diff)
downloadlibexpat-git-6ae5333645afd486c08d078246077cf0e721a5e1.tar.gz
Autotools|CMake: Link against libm for function "isnan"issue-509-link-against-libm
$ git --no-pager grep -lw isnan lib/xmlparse.c tests/runtests.c xmlwf/xmlwf.c
-rw-r--r--.github/workflows/autotools-cmake.yml9
-rw-r--r--expat/CMakeLists.txt16
-rw-r--r--expat/Changes1
-rw-r--r--expat/ConfigureChecks.cmake3
-rw-r--r--expat/cmake/autotools/expat.cmake5
-rw-r--r--expat/configure.ac1
-rw-r--r--expat/expat.pc.cmake2
-rw-r--r--expat/expat.pc.in2
-rw-r--r--expat/lib/Makefile.am1
-rw-r--r--expat/tests/Makefile.am3
-rw-r--r--expat/xmlwf/Makefile.am2
11 files changed, 42 insertions, 3 deletions
diff --git a/.github/workflows/autotools-cmake.yml b/.github/workflows/autotools-cmake.yml
index 306c096b..ed9c94ae 100644
--- a/.github/workflows/autotools-cmake.yml
+++ b/.github/workflows/autotools-cmake.yml
@@ -74,6 +74,7 @@ jobs:
automake \
cmake \
docbook2x \
+ gnu-sed \
libtool \
lzip
@@ -128,6 +129,14 @@ jobs:
&& mv expat-noconfig{-patched,}.cmake )
fi
+ if [[ "${{ runner.os }}" == macOS ]]; then
+ # Autotools' LT_LIB_M has a hardcoded exclude for "*-*-darwin*" hosts,
+ # while macOS does have libm and is successfully found by CMake.
+ # We patch the CMake side in line here to get the differ below to empty.
+ export PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:${PATH}"
+ sed 's,-lm,,' -i build_cmake/ROOT/usr/local/lib*/pkgconfig/expat.pc
+ fi
+
diff \
--recursive \
--unified \
diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt
index dcd9e91f..bccda81c 100644
--- a/expat/CMakeLists.txt
+++ b/expat/CMakeLists.txt
@@ -380,6 +380,9 @@ else()
endif()
add_library(expat ${_SHARED} ${expat_SRCS})
+if(_EXPAT_LIBM_FOUND)
+ target_link_libraries(expat m)
+endif()
if(EXPAT_WITH_LIBBSD)
target_link_libraries(expat ${LIB_BSD})
endif()
@@ -446,6 +449,11 @@ if(EXPAT_BUILD_PKGCONFIG)
string(TOLOWER "${_build_type}" _build_type_lower)
string(TOUPPER "${_build_type}" _build_type_upper)
set_property(TARGET expat PROPERTY "pkgconfig_${_build_type_lower}_name" "expat${CMAKE_${_build_type_upper}_POSTFIX}")
+ if(_EXPAT_LIBM_FOUND)
+ set_property(TARGET expat PROPERTY "pkgconfig_libm" "-lm")
+ else()
+ set_property(TARGET expat PROPERTY "pkgconfig_libm" "")
+ endif()
endforeach()
file(GENERATE
@@ -470,6 +478,9 @@ if(EXPAT_BUILD_TOOLS)
add_executable(xmlwf ${xmlwf_SRCS})
set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)
target_link_libraries(xmlwf expat)
+ if(_EXPAT_LIBM_FOUND)
+ target_link_libraries(xmlwf m)
+ endif()
expat_install(TARGETS xmlwf DESTINATION ${CMAKE_INSTALL_BINDIR})
if(MINGW AND _EXPAT_UNICODE_WCHAR_T)
@@ -543,6 +554,11 @@ if(EXPAT_BUILD_TESTS)
set_property(TARGET runtestspp PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
expat_add_test(runtestspp $<TARGET_FILE:runtestspp>)
+ if(_EXPAT_LIBM_FOUND)
+ target_link_libraries(runtests m)
+ target_link_libraries(runtestspp m)
+ endif()
+
if(EXPAT_WITH_LIBBSD)
target_link_libraries(runtests ${LIB_BSD})
target_link_libraries(runtestspp ${LIB_BSD})
diff --git a/expat/Changes b/expat/Changes
index ed0f4f2b..78ea0832 100644
--- a/expat/Changes
+++ b/expat/Changes
@@ -4,6 +4,7 @@ NOTE: We are looking for help with a few things:
Release 2.4.2 xxx xxx xx xxxx
Other changes:
+ #509 #510 Link againgst libm for function "isnan"
#497 Autotools: Include files with release archives:
- buildconf.sh
- fuzz/*.c
diff --git a/expat/ConfigureChecks.cmake b/expat/ConfigureChecks.cmake
index d85e48c9..638f0aa2 100644
--- a/expat/ConfigureChecks.cmake
+++ b/expat/ConfigureChecks.cmake
@@ -2,6 +2,7 @@ include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckIncludeFiles)
+include(CheckLibraryExists)
include(CheckSymbolExists)
include(TestBigEndian)
@@ -64,3 +65,5 @@ check_c_source_compiles("
check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING)
check_c_compiler_flag("-fvisibility=hidden" FLAG_VISIBILITY)
+
+check_library_exists(m cos "" _EXPAT_LIBM_FOUND)
diff --git a/expat/cmake/autotools/expat.cmake b/expat/cmake/autotools/expat.cmake
index cc2eb1f5..82efb436 100644
--- a/expat/cmake/autotools/expat.cmake
+++ b/expat/cmake/autotools/expat.cmake
@@ -55,8 +55,13 @@ add_library(expat::expat SHARED IMPORTED)
set_target_properties(expat::expat PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
+ INTERFACE_LINK_LIBRARIES "m"
)
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
+endif()
+
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/expat-*.cmake")
diff --git a/expat/configure.ac b/expat/configure.ac
index 6c1016e1..44a954fc 100644
--- a/expat/configure.ac
+++ b/expat/configure.ac
@@ -186,6 +186,7 @@ AM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${
AM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null])
AM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null])
+LT_LIB_M
AC_ARG_WITH([libbsd],
[AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])],
diff --git a/expat/expat.pc.cmake b/expat/expat.pc.cmake
index 89a401af..948e35ff 100644
--- a/expat/expat.pc.cmake
+++ b/expat/expat.pc.cmake
@@ -7,5 +7,5 @@ Name: $<TARGET_PROPERTY:pkgconfig_$<LOWER_CASE:$<CONFIG>>_name>
Version: $<TARGET_PROPERTY:pkgconfig_version>
Description: expat XML parser
URL: https://libexpat.github.io/
-Libs: -L${libdir} -l$<TARGET_PROPERTY:pkgconfig_$<LOWER_CASE:$<CONFIG>>_name>
+Libs: -L${libdir} -l$<TARGET_PROPERTY:pkgconfig_$<LOWER_CASE:$<CONFIG>>_name> $<TARGET_PROPERTY:pkgconfig_libm>
Cflags: -I${includedir}
diff --git a/expat/expat.pc.in b/expat/expat.pc.in
index 3a1a4609..6be6465a 100644
--- a/expat/expat.pc.in
+++ b/expat/expat.pc.in
@@ -7,5 +7,5 @@ Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Description: expat XML parser
URL: https://libexpat.github.io/
-Libs: -L${libdir} -l@PACKAGE_NAME@
+Libs: -L${libdir} -l@PACKAGE_NAME@ @LIBM@
Cflags: -I${includedir}
diff --git a/expat/lib/Makefile.am b/expat/lib/Makefile.am
index 4a11c5e4..d5402496 100644
--- a/expat/lib/Makefile.am
+++ b/expat/lib/Makefile.am
@@ -40,6 +40,7 @@ noinst_LTLIBRARIES = libexpatinternal.la
libexpat_la_LDFLAGS = \
@AM_LDFLAGS@ \
+ @LIBM@ \
-no-undefined \
-version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
diff --git a/expat/tests/Makefile.am b/expat/tests/Makefile.am
index b34a1542..cb68e11e 100644
--- a/expat/tests/Makefile.am
+++ b/expat/tests/Makefile.am
@@ -57,6 +57,9 @@ runtestspp_SOURCES = \
runtests_LDADD = libruntests.a ../lib/libexpatinternal.la
runtestspp_LDADD = libruntests.a ../lib/libexpatinternal.la
+runtests_LDFLAGS = @AM_LDFLAGS@ @LIBM@
+runtestspp_LDFLAGS = @AM_LDFLAGS@ @LIBM@
+
EXTRA_DIST = \
chardata.h \
structdata.h \
diff --git a/expat/xmlwf/Makefile.am b/expat/xmlwf/Makefile.am
index f10a8798..3091e09d 100644
--- a/expat/xmlwf/Makefile.am
+++ b/expat/xmlwf/Makefile.am
@@ -38,7 +38,7 @@ xmlwf_SOURCES = \
@FILEMAP@.c
xmlwf_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
-xmlwf_LDFLAGS = @AM_LDFLAGS@
+xmlwf_LDFLAGS = @AM_LDFLAGS@ @LIBM@
if MINGW
if UNICODE