Skip to content

Commit

Permalink
Adding checks for compiler flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
mithro committed Jun 4, 2019
1 parent 16382b5 commit 7048099
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 7048099

Please sign in to comment.