Skip to content

Commit 7048099

Browse files
committed
Adding checks for compiler flags.
1 parent 16382b5 commit 7048099

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ if(FLEX_BISON_WARN_SUPPRESS_FLAGS)
4040
PROPERTIES COMPILE_FLAGS ${FLEX_BISON_WARN_SUPPRESS_FLAGS})
4141
endif()
4242

43+
# Grammars generated by Bison 3.0.4 and below emit a null pointer dereference warning
44+
# when compiled with GCC 7
45+
include(CheckCXXCompilerFlag)
46+
check_cxx_compiler_flag(-Werror=null-dereference NULL_DEREFERENCE)
47+
if (${NULL_DEREFERENCE} AND ${BISON_VERSION} VERSION_LESS 3.0.5)
48+
get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS)
49+
set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE}
50+
PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-error=null-dereference)
51+
endif()
52+
53+
check_cxx_compiler_flag(-Wswitch-default SWITCH_DEFAULT)
54+
if (${SWITCH_DEFAULT})
55+
get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS)
56+
set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE}
57+
PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-switch-default)
58+
endif()
59+
4360
#Create the library
4461
add_library(libsdcparse STATIC
4562
${LIB_HEADERS}

0 commit comments

Comments
 (0)