add_check_c_cxx_flag("-O${OPTIMIZATION_LEVEL}")
add_check_c_cxx_flag("-Wall")
-add_check_c_cxx_flag("-Wno-unused-private-field")
+add_check_c_cxx_supression_flag("-Wno-unused-private-field")
add_check_c_flag("-fexceptions")
add_check_cxx_flag("-Wsuggest-override")
add_check_cxx_flag("-Wnon-virtual-dtor")
# Temporarily disable -Wclass-memaccess to suppress 'no trivial copy-assignment'
# cdlist.h warnings. Remove when fixed.
-add_check_cxx_flag("-Wno-class-memaccess")
+add_check_cxx_supression_flag("-Wno-class-memaccess")
if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,100000000")
# Check if C flag is supported and add to global list of C flags.
macro(add_check_c_flag flag)
string(REGEX REPLACE "[-=]" "_" flagname ${flag})
- check_c_compiler_flag("${flag}" HAVE_FLAG${flagname})
- if(HAVE_FLAG${flagname})
+ check_c_compiler_flag("${flag}" HAVE_C_FLAG${flagname})
+ if(HAVE_C_FLAG${flagname})
add_c_flag(${flag})
endif()
endmacro()
# Check if CXX flag is supported and add to global list of CXX flags.
macro(add_check_cxx_flag flag)
string(REGEX REPLACE "[-=]" "_" flagname ${flag})
- check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname})
- if(HAVE_FLAG${flagname})
+ check_cxx_compiler_flag("${flag}" HAVE_CXX_FLAG${flagname})
+ if(HAVE_CXX_FLAG${flagname})
add_cxx_flag(${flag})
endif()
endmacro()
add_check_cxx_flag(${flag})
endmacro()
+# Check if C warning suppression flag is supported and add to global list of C
+# flags.
+macro(add_check_c_supression_flag supression_flag)
+ # Obtain the non-supression warning flag name
+ string(REGEX REPLACE "^-Wno-" "-W" warning_flag ${supression_flag})
+ string(REGEX REPLACE "[-=]" "_" warning_flagname ${warning_flag})
+ # Check if we have the warning flag
+ check_c_compiler_flag("${warning_flag}" HAVE_C_FLAG${warning_flagname})
+ # Only add the supression flag if we have the warning flag
+ if(HAVE_C_FLAG${warning_flagname})
+ add_c_flag(${supression_flag})
+ endif()
+endmacro()
+
+# Check if CXX warning suppression flag is supported and add to global list of
+# CXX flags.
+macro(add_check_cxx_supression_flag supression_flag)
+ # Obtain the non-supression warning flag name
+ string(REGEX REPLACE "^-Wno-" "-W" warning_flag ${supression_flag})
+ string(REGEX REPLACE "[-=]" "_" warning_flagname ${warning_flag})
+ # Check if we have the warning flag
+ check_cxx_compiler_flag("${warning_flag}" HAVE_CXX_FLAG${warning_flagname})
+ # Only add the supression flag if we have the warning flag
+ if(HAVE_CXX_FLAG${warning_flagname})
+ add_cxx_flag(${supression_flag})
+ endif()
+endmacro()
+
+# Check if C/CXX warning supression flag is supported and add to global list of
+# C/CXX flags.
+macro(add_check_c_cxx_supression_flag supression_flag)
+ add_check_c_supression_flag(${supression_flag})
+ add_check_cxx_supression_flag(${supression_flag})
+endmacro()
+
# Add required CXX flag. Configuration fails if the CXX flag is not supported
# by the compiler.
macro(add_required_cxx_flag flag)
string(REGEX REPLACE "[-=]" "_" flagnamename ${flag})
- check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname})
- if (NOT HAVE_FLAG${flagname})
+ check_cxx_compiler_flag("${flag}" HAVE_C_FLAG${flagname})
+ if (NOT HAVE_C_FLAG${flagname})
message(FATAL_ERROR "Required compiler flag ${flag} not supported")
endif()
add_cxx_flag(${flag})
# the compiler.
macro(add_required_c_flag flag)
string(REGEX REPLACE "[-=]" "_" flagname ${flag})
- check_c_compiler_flag("${flag}" HAVE_FLAG${flagname})
- if (NOT HAVE_FLAG${flagname})
+ check_c_compiler_flag("${flag}" HAVE_CXX_FLAG${flagname})
+ if (NOT HAVE_CXX_FLAG${flagname})
message(FATAL_ERROR "Required compiler flag ${flag} not supported")
endif()
add_c_flag(${flag})
target_link_libraries(pycvc5 cvc5-shared)
# Disable -Werror and other warnings for code generated by Cython.
+set(PY_SRC_FLAGS "")
+check_cxx_compiler_flag("-Werror" HAVE_CXX_FLAGWerror)
+if(HAVE_CXX_FLAGWerror)
+ set(PY_SRC_FLAGS "${PY_SRC_FLAGS} -Wno-error")
+endif()
+check_cxx_compiler_flag("-Wshadow" HAVE_CXX_FLAGWshadow)
+if(HAVE_CXX_FLAGWshadow)
+ set(PY_SRC_FLAGS "${PY_SRC_FLAGS} -Wno-shadow")
+endif()
+check_cxx_compiler_flag("-Wimplicit-fallthrough" HAVE_CXX_FLAGWimplicit_fallthrough)
+if(HAVE_CXX_FLAGWimplicit_fallthrough)
+ set(PY_SRC_FLAGS "${PY_SRC_FLAGS} -Wno-implicit-fallthrough")
+endif()
# Note: Visibility is reset to default here since otherwise the PyInit_...
# function will not be exported correctly
# (https://github.com/cython/cython/issues/3380).
set_target_properties(pycvc5
PROPERTIES
- COMPILE_FLAGS
- "-Wno-error -Wno-shadow -Wno-implicit-fallthrough"
+ COMPILE_FLAGS "${PY_SRC_FLAGS}"
CXX_VISIBILITY_PRESET default
VISIBILITY_INLINES_HIDDEN 0
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pycvc5")
set_source_files_properties(${gen_src_files} PROPERTIES GENERATED TRUE)
# We don't want to enable -Wall for code generated by ANTLR.
+ set(GEN_SRC_FLAGS "")
+ check_cxx_compiler_flag("-Wall" HAVE_CXX_FLAGWall)
+ if(HAVE_CXX_FLAGWall)
+ set(GEN_SRC_FLAGS "${GEN_SRC_FLAGS} -Wno-all")
+ endif()
+ check_cxx_compiler_flag("-Werror" HAVE_CXX_FLAGWerror)
+ if(HAVE_CXX_FLAGWerror)
+ set(GEN_SRC_FLAGS "${GEN_SRC_FLAGS} -Wno-error")
+ endif()
set_source_files_properties(
- ${gen_src_files} PROPERTIES COMPILE_FLAGS "-Wno-all -Wno-error")
+ ${gen_src_files} PROPERTIES COMPILE_FLAGS "${GEN_SRC_FLAGS}")
# Add generated source files to the parser source files
list(APPEND libcvc5parser_src_files ${gen_src_files})