]> granicus.if.org Git - libexpat/commitdiff
CMake: Prefer check_symbol_exists over check_function_exists
authorBrad King <brad.king@kitware.com>
Tue, 12 Dec 2017 16:31:57 +0000 (11:31 -0500)
committerBrad King <brad.king@kitware.com>
Wed, 13 Dec 2017 12:05:46 +0000 (07:05 -0500)
The `CheckFunctionExists` module documentation recommends using
`CheckSymbolExists` instead.  `check_symbol_exists` verifies that one
can actually include a header file and refer to a symbol.  This is more
robust than just checking whether one can link to a symbol by name.

expat/Changes
expat/ConfigureChecks.cmake

index 3d631f5e6d3b947f64152fbc7b6273f8dd121897..9879203441dc86bd4b7f37ff2486c870a73b34ca 100644 (file)
@@ -11,9 +11,11 @@ Release 2.2.? ???????????????????
                     xmlwf.1 rather than XMLWF.1; also covers case insensitive
                     file systems
             #174  CMake: Introduce option WARNINGS_AS_ERRORS, defaults to OFF
+            #175  CMake: Prefer check_symbol_exists over check_function_exists
             #131  Address compiler warnings
 
         Special thanks to:
+            Brad King
             Franek Korta
             Joe Orton
             Rainer Jung
index d97b397227b6edce7205c1e2d5cb56f6d42368ae..dbb49210202fbc9b5b564ebf728a6e4038b1846d 100644 (file)
@@ -2,7 +2,6 @@ include(CheckCCompilerFlag)
 include(CheckCSourceCompiles)\r
 include(CheckIncludeFile)\r
 include(CheckIncludeFiles)\r
-include(CheckFunctionExists)\r
 include(CheckSymbolExists)\r
 include(TestBigEndian)\r
 \r
@@ -18,18 +17,21 @@ check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
 check_include_file("sys/types.h" HAVE_SYS_TYPES_H)\r
 check_include_file("unistd.h" HAVE_UNISTD_H)\r
 \r
-check_function_exists("getpagesize" HAVE_GETPAGESIZE)\r
-check_function_exists("bcopy" HAVE_BCOPY)\r
+check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)\r
+check_symbol_exists("bcopy" "strings.h" HAVE_BCOPY)\r
 check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE)\r
-check_function_exists("mmap" HAVE_MMAP)\r
-check_function_exists("getrandom" HAVE_GETRANDOM)\r
+check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)\r
+check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)\r
 \r
 if(USE_libbsd)\r
     set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")\r
+    set(_bsd "bsd/")\r
+else()\r
+    set(_bsd "")\r
 endif()\r
-check_function_exists("arc4random_buf" HAVE_ARC4RANDOM_BUF)\r
+check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)\r
 if(NOT HAVE_ARC4RANDOM_BUF)\r
-    check_function_exists("arc4random" HAVE_ARC4RANDOM)\r
+    check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM)\r
 endif()\r
 set(CMAKE_REQUIRED_LIBRARIES)\r
 \r