3
3
cmake_policy (SET CMP0091 NEW )
4
4
endif ()
5
5
6
- project (LibreSSL C ASM )
6
+ project (LibreSSL LANGUAGES C ASM )
7
7
8
8
include (CheckFunctionExists )
9
9
include (CheckSymbolExists )
@@ -200,37 +200,42 @@ else()
200
200
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
201
201
endif ()
202
202
203
+ # XXX - needs _GNU_SOURCE on linux
203
204
check_function_exists (asprintf HAVE_ASPRINTF )
204
205
if (HAVE_ASPRINTF )
205
206
add_definitions (-DHAVE_ASPRINTF )
206
207
endif ()
207
208
208
- check_function_exists (getopt HAVE_GETOPT )
209
+ check_symbol_exists (getopt "unistd.h" HAVE_GETOPT )
209
210
if (HAVE_GETOPT )
210
211
add_definitions (-DHAVE_GETOPT )
211
212
endif ()
212
213
213
- check_function_exists (reallocarray HAVE_REALLOCARRAY )
214
+ check_symbol_exists (reallocarray "stdlib.h" HAVE_REALLOCARRAY )
214
215
if (HAVE_REALLOCARRAY )
215
216
add_definitions (-DHAVE_REALLOCARRAY )
216
217
endif ()
217
218
219
+ # XXX strcasecmp() is in strings.h which isn't available everywhere
218
220
check_function_exists (strcasecmp HAVE_STRCASECMP )
219
221
if (HAVE_STRCASECMP )
220
222
add_definitions (-DHAVE_STRCASECMP )
221
223
endif ()
222
224
223
- check_function_exists (strlcat HAVE_STRLCAT )
224
- if (HAVE_STRLCAT )
225
- add_definitions (-DHAVE_STRLCAT )
226
- endif ()
225
+ # Emscripten's strlcat and strlcpy triggers ASAN errors
226
+ if (NOT EMSCRIPTEN )
227
+ check_symbol_exists (strlcat "string.h" HAVE_STRLCAT )
228
+ if (HAVE_STRLCAT )
229
+ add_definitions (-DHAVE_STRLCAT )
230
+ endif ()
227
231
228
- check_function_exists (strlcpy HAVE_STRLCPY )
229
- if (HAVE_STRLCPY )
230
- add_definitions (-DHAVE_STRLCPY )
232
+ check_symbol_exists (strlcpy "string.h" HAVE_STRLCPY )
233
+ if (HAVE_STRLCPY )
234
+ add_definitions (-DHAVE_STRLCPY )
235
+ endif ()
231
236
endif ()
232
237
233
- check_function_exists (strndup HAVE_STRNDUP )
238
+ check_symbol_exists (strndup "string.h" HAVE_STRNDUP )
234
239
if (HAVE_STRNDUP )
235
240
add_definitions (-DHAVE_STRNDUP )
236
241
endif ()
@@ -239,67 +244,64 @@ if(WIN32)
239
244
set (HAVE_STRNLEN true )
240
245
add_definitions (-DHAVE_STRNLEN )
241
246
else ()
242
- check_function_exists (strnlen HAVE_STRNLEN )
247
+ check_symbol_exists (strnlen "string.h" HAVE_STRNLEN )
243
248
if (HAVE_STRNLEN )
244
249
add_definitions (-DHAVE_STRNLEN )
245
250
endif ()
246
251
endif ()
247
252
248
- check_function_exists (strsep HAVE_STRSEP )
253
+ check_symbol_exists (strsep "string.h" HAVE_STRSEP )
249
254
if (HAVE_STRSEP )
250
255
add_definitions (-DHAVE_STRSEP )
251
256
endif ()
252
257
253
- check_function_exists (strtonum HAVE_STRTONUM )
258
+ check_symbol_exists (strtonum "stdlib.h" HAVE_STRTONUM )
254
259
if (HAVE_STRTONUM )
255
260
add_definitions (-DHAVE_STRTONUM )
256
261
endif ()
257
262
258
- check_function_exists (timegm HAVE_TIMEGM )
259
- if (HAVE_TIMEGM )
260
- add_definitions (-DHAVE_TIMEGM )
261
- endif ()
262
-
263
- check_function_exists (arc4random_buf HAVE_ARC4RANDOM_BUF )
263
+ check_symbol_exists (arc4random_buf "stdlib.h" HAVE_ARC4RANDOM_BUF )
264
264
if (HAVE_ARC4RANDOM_BUF )
265
265
add_definitions (-DHAVE_ARC4RANDOM_BUF )
266
266
endif ()
267
267
268
- check_function_exists (arc4random_uniform HAVE_ARC4RANDOM_UNIFORM )
268
+ check_symbol_exists (arc4random_uniform "stdlib.h" HAVE_ARC4RANDOM_UNIFORM )
269
269
if (HAVE_ARC4RANDOM_UNIFORM )
270
270
add_definitions (-DHAVE_ARC4RANDOM_UNIFORM )
271
271
endif ()
272
272
273
- check_function_exists (explicit_bzero HAVE_EXPLICIT_BZERO )
273
+ check_symbol_exists (explicit_bzero "string.h" HAVE_EXPLICIT_BZERO )
274
274
if (HAVE_EXPLICIT_BZERO )
275
275
add_definitions (-DHAVE_EXPLICIT_BZERO )
276
276
endif ()
277
277
278
- check_function_exists (getauxval HAVE_GETAUXVAL )
278
+ check_symbol_exists (getauxval "sys/auxv.h" HAVE_GETAUXVAL )
279
279
if (HAVE_GETAUXVAL )
280
280
add_definitions (-DHAVE_GETAUXVAL )
281
281
endif ()
282
282
283
+ # XXX macos fails to find getentropy with check_symbol_exists()
283
284
check_function_exists (getentropy HAVE_GETENTROPY )
284
285
if (HAVE_GETENTROPY )
285
286
add_definitions (-DHAVE_GETENTROPY )
286
287
endif ()
287
288
288
- check_symbol_exists (getpagesize unistd.h HAVE_GETPAGESIZE )
289
+ check_symbol_exists (getpagesize " unistd.h" HAVE_GETPAGESIZE )
289
290
if (HAVE_GETPAGESIZE )
290
291
add_definitions (-DHAVE_GETPAGESIZE )
291
292
endif ()
292
293
293
- check_function_exists (getprogname HAVE_GETPROGNAME )
294
+ check_symbol_exists (getprogname "stdlib.h" HAVE_GETPROGNAME )
294
295
if (HAVE_GETPROGNAME )
295
296
add_definitions (-DHAVE_GETPROGNAME )
296
297
endif ()
297
298
298
- check_function_exists (syslog_r HAVE_SYSLOG_R )
299
+ check_symbol_exists (syslog_r "syslog.h;stdarg.h" HAVE_SYSLOG_R )
299
300
if (HAVE_SYSLOG_R )
300
301
add_definitions (-DHAVE_SYSLOG_R )
301
302
endif ()
302
303
304
+ # XXX - needs _GNU_SOURCE on linux
303
305
check_function_exists (syslog HAVE_SYSLOG )
304
306
if (HAVE_SYSLOG )
305
307
add_definitions (-DHAVE_SYSLOG )
@@ -310,16 +312,17 @@ if(HAVE_TIMESPECSUB)
310
312
add_definitions (-DHAVE_TIMESPECSUB )
311
313
endif ()
312
314
313
- check_function_exists (timingsafe_bcmp HAVE_TIMINGSAFE_BCMP )
315
+ check_symbol_exists (timingsafe_bcmp "string.h" HAVE_TIMINGSAFE_BCMP )
314
316
if (HAVE_TIMINGSAFE_BCMP )
315
317
add_definitions (-DHAVE_TIMINGSAFE_BCMP )
316
318
endif ()
317
319
318
- check_function_exists (timingsafe_memcmp HAVE_TIMINGSAFE_MEMCMP )
320
+ check_symbol_exists (timingsafe_memcmp "string.h" HAVE_TIMINGSAFE_MEMCMP )
319
321
if (HAVE_TIMINGSAFE_MEMCMP )
320
322
add_definitions (-DHAVE_TIMINGSAFE_MEMCMP )
321
323
endif ()
322
324
325
+ # XXX - needs _GNU_SOURCE on linux
323
326
check_function_exists (memmem HAVE_MEMMEM )
324
327
if (HAVE_MEMMEM )
325
328
add_definitions (-DHAVE_MEMMEM )
@@ -375,7 +378,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "mips")
375
378
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc" )
376
379
set (HOST_POWERPC true )
377
380
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64" )
378
- set (HOST_PPC64 true )
381
+ set (HOST_POWERPC64 true )
379
382
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64" )
380
383
set (HOST_RISCV64 true )
381
384
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "sparc64" )
@@ -386,21 +389,20 @@ endif()
386
389
387
390
if (ENABLE_ASM )
388
391
if (CMAKE_C_COMPILER_ABI STREQUAL "ELF" )
389
- if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64)" )
392
+ if (HOST_X86_64 )
390
393
set (HOST_ASM_ELF_X86_64 true )
391
- elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND
392
- NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
394
+ elseif (HOST_ARM )
393
395
set (HOST_ASM_ELF_ARMV4 true )
394
- elseif (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR MATCHES "i386" )
396
+ elseif (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND HOST_I386 )
395
397
set (HOST_ASM_ELF_X86_64 true )
396
398
endif ()
397
399
add_definitions (-DHAVE_GNU_STACK )
398
- elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" )
400
+ elseif (APPLE AND HOST_X86_64 )
399
401
set (HOST_ASM_MACOSX_X86_64 true )
400
402
elseif (MSVC AND (CMAKE_GENERATOR MATCHES "Win64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64" ))
401
403
set (HOST_ASM_MASM_X86_64 true )
402
404
ENABLE_LANGUAGE (ASM_MASM )
403
- elseif (MINGW AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" )
405
+ elseif (MINGW AND HOST_X86_64 )
404
406
set (HOST_ASM_MINGW64_X86_64 true )
405
407
endif ()
406
408
endif ()
@@ -509,15 +511,13 @@ if(ENABLE_LIBRESSL_INSTALL)
509
511
"${CMAKE_CURRENT_BINARY_DIR} /LibreSSLConfigVersion.cmake"
510
512
DESTINATION "${LIBRESSL_INSTALL_CMAKEDIR} "
511
513
)
512
- endif ()
513
514
514
- if (ENABLE_LIBRESSL_INSTALL )
515
515
if (NOT MSVC )
516
516
# Create pkgconfig files.
517
517
set (prefix ${CMAKE_INSTALL_PREFIX} )
518
518
set (exec_prefix \${prefix} )
519
519
set (libdir \${exec_prefix} /${CMAKE_INSTALL_LIBDIR} )
520
- set (includedir \${prefix} /include )
520
+ set (includedir \${prefix} /${CMAKE_INSTALL_INCLUDEDIR} )
521
521
if (PLATFORM_LIBS )
522
522
string (REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS} " )
523
523
endif ()
@@ -530,19 +530,17 @@ if(ENABLE_LIBRESSL_INSTALL)
530
530
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /pkgconfig
531
531
DESTINATION ${CMAKE_INSTALL_LIBDIR} )
532
532
endif ()
533
- endif (ENABLE_LIBRESSL_INSTALL )
534
533
535
- if (ENABLE_LIBRESSL_INSTALL )
536
534
install (FILES cert.pem openssl.cnf x509v3.cnf DESTINATION ${CONF_DIR} )
537
535
install (DIRECTORY DESTINATION ${CONF_DIR} /certs )
538
- endif (ENABLE_LIBRESSL_INSTALL )
539
536
540
- if (NOT TARGET uninstall )
541
- configure_file (
542
- "${CMAKE_CURRENT_SOURCE_DIR} /cmake_uninstall.cmake.in"
543
- "${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake"
544
- IMMEDIATE @ONLY )
537
+ if (NOT TARGET uninstall )
538
+ configure_file (
539
+ "${CMAKE_CURRENT_SOURCE_DIR} /cmake_uninstall.cmake.in"
540
+ "${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake"
541
+ IMMEDIATE @ONLY )
545
542
546
- add_custom_target (uninstall
547
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake )
543
+ add_custom_target (uninstall
544
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake )
545
+ endif ()
548
546
endif ()
0 commit comments