Skip to content
Snippets Groups Projects
Commit 4e871c6f authored by Andrea Gussoni's avatar Andrea Gussoni Committed by Alessandro Di Federico
Browse files

Refactored initialization of compilation flags

We now take advantage of a macro to add a series of compilation flags,
macro that also takes care of checking that the flags are supported by
the compiler.

This patch has been developed by Alessandro Di Federico.
parent 0735acd2
No related branches found
No related tags found
No related merge requests found
...@@ -52,21 +52,36 @@ add_definitions("-DQEMU_INSTALL_PATH=\"${QEMU_INSTALL_PATH}\"") ...@@ -52,21 +52,36 @@ add_definitions("-DQEMU_INSTALL_PATH=\"${QEMU_INSTALL_PATH}\"")
add_definitions("-DINSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}\"") add_definitions("-DINSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}\"")
include_directories("${QEMU_INSTALL_PATH}/include/") include_directories("${QEMU_INSTALL_PATH}/include/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -Wno-error=unused-variable") #
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=return-type") # Compiler options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-function") #
# Basic compiler options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
# Additional compiler options
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-Wno-error=noexcept-type" COMPILER_SUPPORTS_WARN_NOEXCEPT_TYPE) macro(add_flag_if_available flag)
if (COMPILER_SUPPORTS_WARN_NOEXCEPT_TYPE) string(REPLACE "-" "_" NAME "${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=noexcept-type") string(REPLACE "+" "_" NAME "${NAME}")
endif() string(REPLACE "=" "_" NAME "${NAME}")
string(REPLACE "__" "_" NAME "${NAME}")
string(TOUPPER "${NAME}" NAME)
CHECK_CXX_COMPILER_FLAG("${flag}" IS_SUPPORTED_${NAME})
if (IS_SUPPORTED_${NAME})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
endif()
endmacro()
# Disable some warnings
add_flag_if_available("-Wno-error=unused-variable")
add_flag_if_available("-Wno-error=unused-function")
add_flag_if_available("-Wno-error=return-type")
add_flag_if_available("-Wno-error=noexcept-type")
add_flag_if_available("-Wno-error=unused-but-set-variable")
add_flag_if_available("-Wno-error=maybe-uninitialized")
add_flag_if_available("-Wno-error=ignored-attributes")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
add_definitions("-D_FILE_OFFSET_BITS=64") add_definitions("-D_FILE_OFFSET_BITS=64")
include_directories(argparse/) include_directories(argparse/)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment