@@ -64,6 +64,7 @@ check_include_file(sys/param.h HAVE_SYS_PARAM_H)
6464check_include_file (arpa/inet.h HAVE_ARPA_INET_H )
6565check_include_file (byteswap.h HAVE_BYTESWAP_H )
6666check_include_file (glob.h HAVE_GLOB_H )
67+ check_include_file (valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H )
6768
6869if (WIN32 )
6970 check_include_file (io.h HAVE_IO_H )
@@ -88,8 +89,10 @@ if (OPENSSL_FOUND)
8889 message (FATAL_ERROR "Could not detect openssl/aes.h" )
8990 endif ()
9091
91- set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
92- check_include_file (openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H )
92+ if (WITH_BLOWFISH_CIPHER)
93+ set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
94+ check_include_file (openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H )
95+ endif ()
9396
9497 set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
9598 check_include_file (openssl/ecdh.h HAVE_OPENSSL_ECDH_H )
@@ -108,6 +111,10 @@ if (OPENSSL_FOUND)
108111 set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
109112 check_function_exists (EVP_aes_128_cbc HAVE_OPENSSL_EVP_AES_CBC )
110113
114+ set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
115+ set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
116+ check_function_exists (EVP_aes_128_gcm HAVE_OPENSSL_EVP_AES_GCM )
117+
111118 set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
112119 set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
113120 check_function_exists (CRYPTO_THREADID_set_callback HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK )
@@ -120,10 +127,16 @@ if (OPENSSL_FOUND)
120127 set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
121128 check_function_exists (EVP_CIPHER_CTX_new HAVE_OPENSSL_EVP_CIPHER_CTX_NEW )
122129
130+ set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
131+ set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
132+ check_function_exists (EVP_KDF_CTX_new_id HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID )
133+
123134 set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
124135 set (CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} )
125136 check_function_exists (RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES )
126137
138+ check_function_exists (OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC )
139+
127140 unset (CMAKE_REQUIRED_INCLUDES)
128141 unset (CMAKE_REQUIRED_LIBRARIES)
129142endif ()
@@ -254,6 +267,14 @@ if (CMAKE_USE_PTHREADS_INIT)
254267 set (HAVE_PTHREAD 1)
255268endif (CMAKE_USE_PTHREADS_INIT )
256269
270+ if (UNIT_TESTING)
271+ if (CMOCKA_FOUND)
272+ set (CMAKE_REQUIRED_LIBRARIES ${CMOCKA_LIBRARIES} )
273+ check_function_exists (cmocka_set_test_filter HAVE_CMOCKA_SET_TEST_FILTER )
274+ unset (CMAKE_REQUIRED_LIBRARIES)
275+ endif ()
276+ endif ()
277+
257278# OPTIONS
258279check_c_source_compiles ("
259280__thread int tls;
@@ -272,19 +293,19 @@ int main(void) {
272293###########################################################
273294# For detecting attributes we need to treat warnings as
274295# errors
275- if (UNIX )
296+ if (UNIX OR MINGW )
276297 # Get warnings for attributs
277- check_c_compiler_flag ("-Wattributs " REQUIRED_FLAGS_WERROR )
298+ check_c_compiler_flag ("-Wattributes " REQUIRED_FLAGS_WERROR )
278299 if (REQUIRED_FLAGS_WERROR)
279- set ( CMAKE_REQUIRED_FLAGS "-Wattributes" )
300+ string ( APPEND CMAKE_REQUIRED_FLAGS "-Wattributes " )
280301 endif ()
281302
282303 # Turn warnings into errors
283304 check_c_compiler_flag ("-Werror" REQUIRED_FLAGS_WERROR )
284305 if (REQUIRED_FLAGS_WERROR)
285- set ( CMAKE_REQUIRED_FLAGS "-Werror" )
306+ string ( APPEND CMAKE_REQUIRED_FLAGS "-Werror " )
286307 endif ()
287- endif (UNIX )
308+ endif ()
288309
289310check_c_source_compiles ("
290311void test_constructor_attribute(void) __attribute__ ((constructor));
@@ -328,6 +349,28 @@ int main(void) {
328349 return 0;
329350}" HAVE_FALLTHROUGH_ATTRIBUTE )
330351
352+ if (NOT WIN32 )
353+ check_c_source_compiles ("
354+ #define __unused __attribute__((unused))
355+
356+ static int do_nothing(int i __unused)
357+ {
358+ return 0;
359+ }
360+
361+ int main(void)
362+ {
363+ int i;
364+
365+ i = do_nothing(5);
366+ if (i > 5) {
367+ return 1;
368+ }
369+
370+ return 0;
371+ }" HAVE_UNUSED_ATTRIBUTE )
372+ endif ()
373+
331374check_c_source_compiles ("
332375#include <string.h>
333376
@@ -340,18 +383,6 @@ int main(void)
340383 return 0;
341384}" HAVE_GCC_VOLATILE_MEMORY_PROTECTION )
342385
343- check_c_source_compiles ("
344- #include <stdio.h>
345- #define __VA_NARG__(...) (__VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) - 1)
346- #define __VA_NARG_(...) __VA_ARG_N(__VA_ARGS__)
347- #define __VA_ARG_N( _1, _2, _3, _4, _5, _6, _7, _8, _9,_10,N,...) N
348- #define __RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
349- #define myprintf(format, ...) printf((format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__)
350- int main(void) {
351- myprintf(\" %d %d %d %d\" ,1,2,3);
352- return 0;
353- }" HAVE_GCC_NARG_MACRO )
354-
355386check_c_source_compiles ("
356387#include <stdio.h>
357388int main(void) {
@@ -366,6 +397,8 @@ int main(void) {
366397 return 0;
367398}" HAVE_COMPILER__FUNCTION__ )
368399
400+ # This is only available with OpenBSD's gcc implementation */
401+ if (OPENBSD)
369402check_c_source_compiles ("
370403#define ARRAY_LEN 16
371404void test_attr(const unsigned char *k)
@@ -374,6 +407,7 @@ void test_attr(const unsigned char *k)
374407int main(void) {
375408 return 0;
376409}" HAVE_GCC_BOUNDED_ATTRIBUTE )
410+ endif (OPENBSD )
377411
378412# Stop treating warnings as errors
379413unset (CMAKE_REQUIRED_FLAGS)
0 commit comments