@@ -7,8 +7,8 @@ include(CheckTypeSize)
77include (CheckCXXSourceCompiles )
88include (TestBigEndian )
99
10- set (PACKAGE ${APPLICATION_NAME } )
11- set (VERSION ${APPLICATION_VERSION } )
10+ set (PACKAGE ${PROJECT_NAME } )
11+ set (VERSION ${PROJECT_VERSION } )
1212set (DATADIR ${DATA_INSTALL_DIR} )
1313set (LIBDIR ${LIB_INSTALL_DIR} )
1414set (PLUGINDIR "${PLUGIN_INSTALL_DIR} -${LIBRARY_SOVERSION} " )
@@ -267,25 +267,47 @@ int main(void) {
267267 return 0;
268268}" HAVE_MSC_THREAD_LOCAL_STORAGE )
269269
270+ ###########################################################
271+ # For detecting attributes we need to treat warnings as
272+ # errors
273+ if (UNIX )
274+ set (CMAKE_REQUIRED_FLAGS "-Werror" )
275+ endif (UNIX )
276+
270277check_c_source_compiles ("
271- #define FALL_THROUGH __attribute__((fallthrough))
278+ void test_constructor_attribute(void) __attribute__ ((constructor));
272279
273- enum direction_e {
274- UP = 0,
275- DOWN,
276- };
280+ void test_constructor_attribute(void)
281+ {
282+ return;
283+ }
277284
278285int main(void) {
279- enum direction_e key = UP;
280- int i = 10;
281- int j = 0;
286+ return 0;
287+ }" HAVE_CONSTRUCTOR_ATTRIBUTE )
282288
283- switch (key) {
284- case UP:
285- i = 5;
289+ check_c_source_compiles ("
290+ void test_destructor_attribute(void) __attribute__ ((destructor));
291+
292+ void test_destructor_attribute(void)
293+ {
294+ return;
295+ }
296+
297+ int main(void) {
298+ return 0;
299+ }" HAVE_DESTRUCTOR_ATTRIBUTE )
300+
301+ check_c_source_compiles ("
302+ #define FALL_THROUGH __attribute__((fallthrough))
303+
304+ int main(void) {
305+ int i = 2;
306+
307+ switch (i) {
308+ case 0:
286309 FALL_THROUGH;
287- case DOWN:
288- j = i * 2;
310+ case 1:
289311 break;
290312 default:
291313 break;
@@ -332,11 +354,17 @@ int main(void) {
332354 return 0;
333355}" HAVE_COMPILER__FUNCTION__ )
334356
357+ # Stop treating warnings as errors
358+ unset (CMAKE_REQUIRED_FLAGS)
335359
336360check_c_source_compiles ("
337- void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits)
338- __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)));
339- int main(void) { return 0; }" HAVE_GCC_BOUNDED_ATTRIBUTE )
361+ #define ARRAY_LEN 16
362+ void test_attr(const unsigned char *k)
363+ __attribute__((__bounded__(__minbytes__, 2, 16)));
364+
365+ int main(void) {
366+ return 0;
367+ }" HAVE_GCC_BOUNDED_ATTRIBUTE )
340368
341369if (WITH_DEBUG_CRYPTO)
342370 set (DEBUG_CRYPTO 1)
0 commit comments