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) .