Add support for the C++11 keyword 'override'

fixes #8842
This commit is contained in:
Gunnar Beutner 2015-03-23 07:55:06 +01:00
parent dda273dbcc
commit 665c3b45c1
3 changed files with 33 additions and 0 deletions

View File

@ -196,6 +196,29 @@ if(HAVE_LIBEXECINFO)
set(HAVE_BACKTRACE_SYMBOLS TRUE) set(HAVE_BACKTRACE_SYMBOLS TRUE)
endif() endif()
if(UNIX)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" CXX_FLAG_CXX11)
check_cxx_compiler_flag("-std=c++0x" CXX_FLAG_CXX0X)
if(CXX_FLAG_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(CXX_FLAG_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
check_cxx_compiler_flag("-Wno-inconsistent-missing-override" CXX_FLAG_NO_OVERRIDE_WARNING)
if(CXX_FLAG_NO_OVERRIDE_WARNING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")
endif()
endif()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)
if(NOT CXX_FEATURE_OVERRIDE)
add_definitions("-Doverride=")
endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES)
install( install(

View File

@ -24,6 +24,11 @@ set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc PROPERTY EXCLUD
flex_target(config_lexer config_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc) flex_target(config_lexer config_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE) set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE)
if(UNIX)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc PROPERTY COMPILE_FLAGS "-Wno-deprecated-register")
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc PROPERTY COMPILE_FLAGS "-Wno-deprecated-register")
endif()
add_flex_bison_dependency(config_lexer config_parser) add_flex_bison_dependency(config_lexer config_parser)
mkembedconfig_target(base-type.conf base-type.cpp) mkembedconfig_target(base-type.conf base-type.cpp)

View File

@ -22,6 +22,11 @@ bison_target(class_parser class_parser.yy ${CMAKE_CURRENT_BINARY_DIR}/class_pars
flex_target(class_lexer class_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/class_lexer.cc) flex_target(class_lexer class_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/class_lexer.cc)
add_flex_bison_dependency(class_lexer class_parser) add_flex_bison_dependency(class_lexer class_parser)
if(UNIX)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/class_parser.cc PROPERTY COMPILE_FLAGS "-Wno-deprecated-register")
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/class_lexer.cc PROPERTY COMPILE_FLAGS "-Wno-deprecated-register")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_executable(mkclass mkclass.cpp classcompiler.cpp classcompiler.hpp ${FLEX_class_lexer_OUTPUTS} ${BISON_class_parser_OUTPUTS}) add_executable(mkclass mkclass.cpp classcompiler.cpp classcompiler.hpp ${FLEX_class_lexer_OUTPUTS} ${BISON_class_parser_OUTPUTS})