diff options
| author | Brent Cook <busterb@gmail.com> | 2024-10-01 04:00:46 -0500 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2024-10-01 04:00:46 -0500 |
| commit | c169d7e61e39cfdb836e1b0af3618af514defec5 (patch) | |
| tree | 50fe504816d229da2fbab630ea040625dae69558 | |
| parent | c04ca241de17cb5a9f69dfbae7bee2ee49700a40 (diff) | |
| parent | 1ff9793deee907efcbd4769fe99e133a9608a5f6 (diff) | |
| download | portable-c169d7e61e39cfdb836e1b0af3618af514defec5.tar.gz portable-c169d7e61e39cfdb836e1b0af3618af514defec5.tar.bz2 portable-c169d7e61e39cfdb836e1b0af3618af514defec5.zip | |
Land #1079, Switch to check_symbol_exists() for simple cases
| -rw-r--r-- | CMakeLists.txt | 39 | ||||
| -rw-r--r-- | apps/nc/CMakeLists.txt | 2 |
2 files changed, 23 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d42334..4f05c3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -200,21 +200,23 @@ else() | |||
| 200 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | 200 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") |
| 201 | endif() | 201 | endif() |
| 202 | 202 | ||
| 203 | # XXX - needs _GNU_SOURCE on linux | ||
| 203 | check_function_exists(asprintf HAVE_ASPRINTF) | 204 | check_function_exists(asprintf HAVE_ASPRINTF) |
| 204 | if(HAVE_ASPRINTF) | 205 | if(HAVE_ASPRINTF) |
| 205 | add_definitions(-DHAVE_ASPRINTF) | 206 | add_definitions(-DHAVE_ASPRINTF) |
| 206 | endif() | 207 | endif() |
| 207 | 208 | ||
| 208 | check_function_exists(getopt HAVE_GETOPT) | 209 | check_symbol_exists(getopt "unistd.h" HAVE_GETOPT) |
| 209 | if(HAVE_GETOPT) | 210 | if(HAVE_GETOPT) |
| 210 | add_definitions(-DHAVE_GETOPT) | 211 | add_definitions(-DHAVE_GETOPT) |
| 211 | endif() | 212 | endif() |
| 212 | 213 | ||
| 213 | check_function_exists(reallocarray HAVE_REALLOCARRAY) | 214 | check_symbol_exists(reallocarray "stdlib.h" HAVE_REALLOCARRAY) |
| 214 | if(HAVE_REALLOCARRAY) | 215 | if(HAVE_REALLOCARRAY) |
| 215 | add_definitions(-DHAVE_REALLOCARRAY) | 216 | add_definitions(-DHAVE_REALLOCARRAY) |
| 216 | endif() | 217 | endif() |
| 217 | 218 | ||
| 219 | # XXX strcasecmp() is in strings.h which isn't available everywhere | ||
| 218 | check_function_exists(strcasecmp HAVE_STRCASECMP) | 220 | check_function_exists(strcasecmp HAVE_STRCASECMP) |
| 219 | if(HAVE_STRCASECMP) | 221 | if(HAVE_STRCASECMP) |
| 220 | add_definitions(-DHAVE_STRCASECMP) | 222 | add_definitions(-DHAVE_STRCASECMP) |
| @@ -222,18 +224,18 @@ endif() | |||
| 222 | 224 | ||
| 223 | # Emscripten's strlcat and strlcpy triggers ASAN errors | 225 | # Emscripten's strlcat and strlcpy triggers ASAN errors |
| 224 | if(NOT EMSCRIPTEN) | 226 | if(NOT EMSCRIPTEN) |
| 225 | check_function_exists(strlcat HAVE_STRLCAT) | 227 | check_symbol_exists(strlcat "string.h" HAVE_STRLCAT) |
| 226 | if(HAVE_STRLCAT) | 228 | if(HAVE_STRLCAT) |
| 227 | add_definitions(-DHAVE_STRLCAT) | 229 | add_definitions(-DHAVE_STRLCAT) |
| 228 | endif() | 230 | endif() |
| 229 | 231 | ||
| 230 | check_function_exists(strlcpy HAVE_STRLCPY) | 232 | check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY) |
| 231 | if(HAVE_STRLCPY) | 233 | if(HAVE_STRLCPY) |
| 232 | add_definitions(-DHAVE_STRLCPY) | 234 | add_definitions(-DHAVE_STRLCPY) |
| 233 | endif() | 235 | endif() |
| 234 | endif() | 236 | endif() |
| 235 | 237 | ||
| 236 | check_function_exists(strndup HAVE_STRNDUP) | 238 | check_symbol_exists(strndup "string.h" HAVE_STRNDUP) |
| 237 | if(HAVE_STRNDUP) | 239 | if(HAVE_STRNDUP) |
| 238 | add_definitions(-DHAVE_STRNDUP) | 240 | add_definitions(-DHAVE_STRNDUP) |
| 239 | endif() | 241 | endif() |
| @@ -242,62 +244,64 @@ if(WIN32) | |||
| 242 | set(HAVE_STRNLEN true) | 244 | set(HAVE_STRNLEN true) |
| 243 | add_definitions(-DHAVE_STRNLEN) | 245 | add_definitions(-DHAVE_STRNLEN) |
| 244 | else() | 246 | else() |
| 245 | check_function_exists(strnlen HAVE_STRNLEN) | 247 | check_symbol_exists(strnlen "string.h" HAVE_STRNLEN) |
| 246 | if(HAVE_STRNLEN) | 248 | if(HAVE_STRNLEN) |
| 247 | add_definitions(-DHAVE_STRNLEN) | 249 | add_definitions(-DHAVE_STRNLEN) |
| 248 | endif() | 250 | endif() |
| 249 | endif() | 251 | endif() |
| 250 | 252 | ||
| 251 | check_function_exists(strsep HAVE_STRSEP) | 253 | check_symbol_exists(strsep "string.h" HAVE_STRSEP) |
| 252 | if(HAVE_STRSEP) | 254 | if(HAVE_STRSEP) |
| 253 | add_definitions(-DHAVE_STRSEP) | 255 | add_definitions(-DHAVE_STRSEP) |
| 254 | endif() | 256 | endif() |
| 255 | 257 | ||
| 256 | check_function_exists(strtonum HAVE_STRTONUM) | 258 | check_symbol_exists(strtonum "stdlib.h" HAVE_STRTONUM) |
| 257 | if(HAVE_STRTONUM) | 259 | if(HAVE_STRTONUM) |
| 258 | add_definitions(-DHAVE_STRTONUM) | 260 | add_definitions(-DHAVE_STRTONUM) |
| 259 | endif() | 261 | endif() |
| 260 | 262 | ||
| 261 | check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF) | 263 | check_symbol_exists(arc4random_buf "stdlib.h" HAVE_ARC4RANDOM_BUF) |
| 262 | if(HAVE_ARC4RANDOM_BUF) | 264 | if(HAVE_ARC4RANDOM_BUF) |
| 263 | add_definitions(-DHAVE_ARC4RANDOM_BUF) | 265 | add_definitions(-DHAVE_ARC4RANDOM_BUF) |
| 264 | endif() | 266 | endif() |
| 265 | 267 | ||
| 266 | check_function_exists(arc4random_uniform HAVE_ARC4RANDOM_UNIFORM) | 268 | check_symbol_exists(arc4random_uniform "stdlib.h" HAVE_ARC4RANDOM_UNIFORM) |
| 267 | if(HAVE_ARC4RANDOM_UNIFORM) | 269 | if(HAVE_ARC4RANDOM_UNIFORM) |
| 268 | add_definitions(-DHAVE_ARC4RANDOM_UNIFORM) | 270 | add_definitions(-DHAVE_ARC4RANDOM_UNIFORM) |
| 269 | endif() | 271 | endif() |
| 270 | 272 | ||
| 271 | check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) | 273 | check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO) |
| 272 | if(HAVE_EXPLICIT_BZERO) | 274 | if(HAVE_EXPLICIT_BZERO) |
| 273 | add_definitions(-DHAVE_EXPLICIT_BZERO) | 275 | add_definitions(-DHAVE_EXPLICIT_BZERO) |
| 274 | endif() | 276 | endif() |
| 275 | 277 | ||
| 276 | check_function_exists(getauxval HAVE_GETAUXVAL) | 278 | check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL) |
| 277 | if(HAVE_GETAUXVAL) | 279 | if(HAVE_GETAUXVAL) |
| 278 | add_definitions(-DHAVE_GETAUXVAL) | 280 | add_definitions(-DHAVE_GETAUXVAL) |
| 279 | endif() | 281 | endif() |
| 280 | 282 | ||
| 283 | # XXX macos fails to find getentropy with check_symbol_exists() | ||
| 281 | check_function_exists(getentropy HAVE_GETENTROPY) | 284 | check_function_exists(getentropy HAVE_GETENTROPY) |
| 282 | if(HAVE_GETENTROPY) | 285 | if(HAVE_GETENTROPY) |
| 283 | add_definitions(-DHAVE_GETENTROPY) | 286 | add_definitions(-DHAVE_GETENTROPY) |
| 284 | endif() | 287 | endif() |
| 285 | 288 | ||
| 286 | check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) | 289 | check_symbol_exists(getpagesize "unistd.h" HAVE_GETPAGESIZE) |
| 287 | if(HAVE_GETPAGESIZE) | 290 | if(HAVE_GETPAGESIZE) |
| 288 | add_definitions(-DHAVE_GETPAGESIZE) | 291 | add_definitions(-DHAVE_GETPAGESIZE) |
| 289 | endif() | 292 | endif() |
| 290 | 293 | ||
| 291 | check_function_exists(getprogname HAVE_GETPROGNAME) | 294 | check_symbol_exists(getprogname "stdlib.h" HAVE_GETPROGNAME) |
| 292 | if(HAVE_GETPROGNAME) | 295 | if(HAVE_GETPROGNAME) |
| 293 | add_definitions(-DHAVE_GETPROGNAME) | 296 | add_definitions(-DHAVE_GETPROGNAME) |
| 294 | endif() | 297 | endif() |
| 295 | 298 | ||
| 296 | check_function_exists(syslog_r HAVE_SYSLOG_R) | 299 | check_symbol_exists(syslog_r "syslog.h stdarg.h" HAVE_SYSLOG_R) |
| 297 | if(HAVE_SYSLOG_R) | 300 | if(HAVE_SYSLOG_R) |
| 298 | add_definitions(-DHAVE_SYSLOG_R) | 301 | add_definitions(-DHAVE_SYSLOG_R) |
| 299 | endif() | 302 | endif() |
| 300 | 303 | ||
| 304 | # XXX - needs _GNU_SOURCE on linux | ||
| 301 | check_function_exists(syslog HAVE_SYSLOG) | 305 | check_function_exists(syslog HAVE_SYSLOG) |
| 302 | if(HAVE_SYSLOG) | 306 | if(HAVE_SYSLOG) |
| 303 | add_definitions(-DHAVE_SYSLOG) | 307 | add_definitions(-DHAVE_SYSLOG) |
| @@ -308,16 +312,17 @@ if(HAVE_TIMESPECSUB) | |||
| 308 | add_definitions(-DHAVE_TIMESPECSUB) | 312 | add_definitions(-DHAVE_TIMESPECSUB) |
| 309 | endif() | 313 | endif() |
| 310 | 314 | ||
| 311 | check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) | 315 | check_symbol_exists(timingsafe_bcmp "string.h" HAVE_TIMINGSAFE_BCMP) |
| 312 | if(HAVE_TIMINGSAFE_BCMP) | 316 | if(HAVE_TIMINGSAFE_BCMP) |
| 313 | add_definitions(-DHAVE_TIMINGSAFE_BCMP) | 317 | add_definitions(-DHAVE_TIMINGSAFE_BCMP) |
| 314 | endif() | 318 | endif() |
| 315 | 319 | ||
| 316 | check_function_exists(timingsafe_memcmp HAVE_TIMINGSAFE_MEMCMP) | 320 | check_symbol_exists(timingsafe_memcmp "string.h" HAVE_TIMINGSAFE_MEMCMP) |
| 317 | if(HAVE_TIMINGSAFE_MEMCMP) | 321 | if(HAVE_TIMINGSAFE_MEMCMP) |
| 318 | add_definitions(-DHAVE_TIMINGSAFE_MEMCMP) | 322 | add_definitions(-DHAVE_TIMINGSAFE_MEMCMP) |
| 319 | endif() | 323 | endif() |
| 320 | 324 | ||
| 325 | # XXX - needs _GNU_SOURCE on linux | ||
| 321 | check_function_exists(memmem HAVE_MEMMEM) | 326 | check_function_exists(memmem HAVE_MEMMEM) |
| 322 | if(HAVE_MEMMEM) | 327 | if(HAVE_MEMMEM) |
| 323 | add_definitions(-DHAVE_MEMMEM) | 328 | add_definitions(-DHAVE_MEMMEM) |
diff --git a/apps/nc/CMakeLists.txt b/apps/nc/CMakeLists.txt index 7bbdb02..d5f7813 100644 --- a/apps/nc/CMakeLists.txt +++ b/apps/nc/CMakeLists.txt | |||
| @@ -22,7 +22,7 @@ else() | |||
| 22 | set(NC_SRC ${NC_SRC} compat/accept4.c) | 22 | set(NC_SRC ${NC_SRC} compat/accept4.c) |
| 23 | endif() | 23 | endif() |
| 24 | 24 | ||
| 25 | check_function_exists(readpassphrase HAVE_READPASSPHRASE) | 25 | check_symbol_exists(readpassphrase "readpassphrase.h" HAVE_READPASSPHRASE) |
| 26 | if(HAVE_READPASSPHRASE) | 26 | if(HAVE_READPASSPHRASE) |
| 27 | add_definitions(-DHAVE_READPASSPHRASE) | 27 | add_definitions(-DHAVE_READPASSPHRASE) |
| 28 | else() | 28 | else() |
