diff --git a/CMakeLists.txt b/CMakeLists.txt index ddbec4c..564b8a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,23 @@ if(FLEX_BISON_WARN_SUPPRESS_FLAGS) PROPERTIES COMPILE_FLAGS ${FLEX_BISON_WARN_SUPPRESS_FLAGS}) endif() +# Grammars generated by Bison 3.0.4 and below emit a null pointer dereference warning +# when compiled with GCC 7 +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-Werror=null-dereference NULL_DEREFERENCE) +if (${NULL_DEREFERENCE} AND ${BISON_VERSION} VERSION_LESS 3.0.5) + get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS) + set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE} + PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-error=null-dereference) +endif() + +check_cxx_compiler_flag(-Wswitch-default SWITCH_DEFAULT) +if (${SWITCH_DEFAULT}) + get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS) + set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE} + PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-switch-default) +endif() + #Create the library add_library(libsdcparse STATIC ${LIB_HEADERS}