From ac2fd6524afdbaa42266b2c8c198eac7a7ca0a18 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Tue, 18 Aug 2020 21:59:46 +0300 Subject: [PATCH] Support building on e2k (Elbrus) architecture Signed-off-by: makise-homura --- CMakeLists.txt | 15 ++++++++++++++- ChangeLog.d/e2k-support.txt | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ChangeLog.d/e2k-support.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index f8df14007..3fb4d364d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,8 @@ endfunction(link_to_source) string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") +include(CheckCCompilerFlag) + if(CMAKE_COMPILER_IS_GNU) # some warnings we want are not available with old GCC versions # note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION @@ -168,7 +170,18 @@ if(CMAKE_COMPILER_IS_GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow") endif() if (GCC_VERSION VERSION_GREATER 5.0) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-signedness") + CHECK_C_COMPILER_FLAG("-Wformat-signedness" C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS) + if(C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-signedness") + endif() + endif() + CHECK_C_COMPILER_FLAG("-Wno-signed-one-bit-field" C_COMPILER_SUPPORTS_WSIGNED_ONE_BIT_FIELD) + if(C_COMPILER_SUPPORTS_WSIGNED_ONE_BIT_FIELD) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-signed-one-bit-field") + endif() + CHECK_C_COMPILER_FLAG("-Wno-sign-compare" C_COMPILER_SUPPORTS_WSIGN_COMPARE) + if(C_COMPILER_SUPPORTS_WSIGN_COMPARE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-compare") endif() set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_DEBUG "-O0 -g3") diff --git a/ChangeLog.d/e2k-support.txt b/ChangeLog.d/e2k-support.txt new file mode 100644 index 000000000..19cc3ad68 --- /dev/null +++ b/ChangeLog.d/e2k-support.txt @@ -0,0 +1,5 @@ +Features + * Support building on e2k (Elbrus) architecture: correctly enable + -Wformat-signedness, and pass -Wno-signed-one-bit-field and + -Wno-sign-compare to get rid of excess warnings. Contributed by + makise-homura (Igor Molchanov) .