@@ -5,7 +5,7 @@ cmake_policy(SET CMP0091 NEW)
5
5
endif ()
6
6
7
7
set (SOFTWARE_NAME "awslc" )
8
- set (SOFTWARE_VERSION "1.60 .0" )
8
+ set (SOFTWARE_VERSION "1.61 .0" )
9
9
set (ABI_VERSION 0)
10
10
set (CRYPTO_LIB_NAME "crypto" )
11
11
set (SSL_LIB_NAME "ssl" )
@@ -31,6 +31,26 @@ endif()
31
31
32
32
include (sources .cmake)
33
33
include (TestBigEndian)
34
+ include (CheckCCompilerFlag)
35
+
36
+ macro (add_flag_if_supported VARIABLE FLAG)
37
+ # Create a safe, unique variable name to cache the result of the check
38
+ string (MAKE_C_IDENTIFIER "HAVE_C_FLAG_${FLAG} " _CHECK_VAR_NAME)
39
+
40
+ # Keep configure output tidy
41
+ set (CMAKE_REQUIRED_QUIET ${CMAKE_NOT_VERBOSE} )
42
+
43
+ # Run the check only once to speed up re-configuration
44
+ if (NOT DEFINED ${_CHECK_VAR_NAME} )
45
+ check_c_compiler_flag("${FLAG} " ${_CHECK_VAR_NAME} )
46
+ endif ()
47
+
48
+ # If the check passed, append the flag to the specified variable
49
+ if (${_CHECK_VAR_NAME} )
50
+ set (${VARIABLE} "${${VARIABLE} } ${FLAG} " )
51
+ message (STATUS "Compiler supports '${FLAG} ', adding to ${VARIABLE} " )
52
+ endif ()
53
+ endmacro ()
34
54
35
55
if (POLICY CMP0077)
36
56
cmake_policy (SET CMP0077 NEW) #option does nothing when a normal variable of the same name exists.
@@ -474,12 +494,9 @@ if(GCC OR CLANG)
474
494
endif ()
475
495
set (C_CXX_FLAGS "${C_CXX_FLAGS} -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings" )
476
496
477
- if ((GCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "8" ) OR
478
- (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13" ))
479
- # GCC 8.x added a warning called -Wcast-function-type to the -Wextra umbrella.
480
- # Also suppress for all clang versions supporting this warning.
481
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-cast-function-type" )
482
- endif ()
497
+ # GCC 8.x added a warning called -Wcast-function-type to the -Wextra umbrella.
498
+ # Also suppress for all clang versions supporting this warning.
499
+ add_flag_if_supported(CMAKE_C_FLAGS "-Wno-cast-function-type" )
483
500
484
501
if (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug" OR CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithdebinfo" )
485
502
if (MSVC )
@@ -503,31 +520,24 @@ if(GCC OR CLANG)
503
520
504
521
if (CLANG)
505
522
set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -fcolor-diagnostics" )
506
- elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.1.3" )
523
+ else ( )
507
524
# GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls
508
525
# and declare that the code is trying to free a stack pointer. GCC 4.1.3 and lower
509
526
# doesn't support this flag and can't use it.
510
- set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object" )
527
+ add_flag_if_supported (C_CXX_FLAGS "-Wno-free-nonheap-object" )
511
528
# GCC (from at least 4.8) does not include -Wmissing-braces in -Wall due to Bug 25137.
512
529
# This warning is turned on everywhere internally however, so we have to define it here
513
530
# to check that our changes don't break the build.
514
531
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
515
- set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wmissing-braces" )
532
+ add_flag_if_supported (C_CXX_FLAGS "-Wmissing-braces" )
516
533
endif ()
517
534
518
535
# -Wstring-concatenation was added in Clang 12.0.0, which corresponds to
519
536
# AppleClang 13.0.0 per the table in
520
537
# https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
521
- if ((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
522
- NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS "12.0.0" )) OR
523
- (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND
524
- NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0" )))
525
- set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wstring-concatenation" )
526
- endif ()
538
+ add_flag_if_supported(C_CXX_FLAGS "-Wstring-concatenation" )
527
539
528
- if (CLANG OR NOT "7.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
529
- set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough" )
530
- endif ()
540
+ add_flag_if_supported(C_CXX_FLAGS "-Wimplicit-fallthrough" )
531
541
532
542
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5" )
533
543
set (C_CXX_FLAGS "${C_CXX_FLAGS} -Wformat-signedness" )
@@ -674,11 +684,7 @@ if(WIN32)
674
684
add_definitions ("-D_STL_EXTRA_DISABLED_WARNINGS=4774 4987" )
675
685
endif ()
676
686
677
- if ((GCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.9.99" ) OR
678
- CLANG)
679
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow" )
680
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow" )
681
- endif ()
687
+ add_flag_if_supported(C_CXX_FLAGS "-Wshadow" )
682
688
683
689
# pthread_rwlock_t on Linux requires a feature flag. We limit this to Linux
684
690
# because, on Apple platforms, it instead disables APIs we use. See compat(5)
0 commit comments