aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2020-01-21 21:53:43 +0100
committerMarvin W <git@larma.de>2020-01-21 21:55:08 +0100
commit4a9c05ea372e8f1279644ad6dc519ca407aec88a (patch)
treee76c9dfa5a716831a9f3496353d304c15fce84a0 /CMakeLists.txt
parent55b148a0f78c1abef57c21b2a84d97cad32b2290 (diff)
downloaddino-4a9c05ea372e8f1279644ad6dc519ca407aec88a.tar.gz
dino-4a9c05ea372e8f1279644ad6dc519ca407aec88a.zip
Enabling display of more compiler warnings and fix some of them
Most of these are caused by various issues is the Vala compiler, but it doesn't hurt to display them and report them upstream.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt68
1 files changed, 44 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13c84af7..06810ef2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.3)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(ComputeVersion)
if (NOT VERSION_FOUND)
@@ -88,45 +88,65 @@ set(PLUGIN_INSTALL LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} RUNTIME DESTINATION
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
-macro(AddCFlagIfSupported flag)
+macro(AddCFlagIfSupported list flag)
string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag})
check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name})
if (${COMPILER_SUPPORTS${flag_name}})
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
- endif ()
-endmacro()
-
-macro(AddValaCFlagIfSupported flag)
- string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag})
- check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name})
- if (${COMPILER_SUPPORTS${flag_name}})
- set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}")
+ set(${list} "${${list}} ${flag}")
endif ()
endmacro()
if ("Ninja" STREQUAL ${CMAKE_GENERATOR})
- AddCFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnistics-color)
+ AddCFlagIfSupported(CMAKE_C_FLAGS -fdiagnostics-color)
+endif ()
+
+# Flags for all C files
+AddCFlagIfSupported(CMAKE_C_FLAGS -Wall)
+AddCFlagIfSupported(CMAKE_C_FLAGS -Wextra)
+AddCFlagIfSupported(CMAKE_C_FLAGS -Werror=format-security)
+AddCFlagIfSupported(CMAKE_C_FLAGS -Wno-duplicate-decl-specifier)
+
+if (NOT VALA_WARN)
+ set(VALA_WARN "conversion")
+endif ()
+set(VALA_WARN "${VALA_WARN}" CACHE STRING "Which warnings to show when invoking C compiler on Vala compiler output")
+set_property(CACHE VALA_WARN PROPERTY STRINGS "all;unused;qualifier;conversion;deprecated;format;none")
+
+# Vala generates some unused stuff
+if (NOT ("all" IN_LIST VALA_WARN OR "unused" IN_LIST VALA_WARN))
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-but-set-variable)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-function)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-label)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-parameter)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-value)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-unused-variable)
+endif ()
+
+if (NOT ("all" IN_LIST VALA_WARN OR "qualifier" IN_LIST VALA_WARN))
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-discarded-qualifiers)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-discarded-array-qualifiers)
endif ()
-AddCFlagIfSupported(-Wall)
-AddCFlagIfSupported(-Werror=format-security)
+if (NOT ("all" IN_LIST VALA_WARN OR "deprecated" IN_LIST VALA_WARN))
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-deprecated-declarations)
+endif ()
+
+if (NOT ("all" IN_LIST VALA_WARN OR "format" IN_LIST VALA_WARN))
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-missing-braces)
+endif ()
-AddValaCFlagIfSupported(-Wno-incompatible-pointer-types)
-AddValaCFlagIfSupported(-Wno-pointer-sign)
-AddValaCFlagIfSupported(-Wno-int-conversion)
-AddValaCFlagIfSupported(-Wno-discarded-qualifiers)
-AddValaCFlagIfSupported(-Wno-unused-but-set-variable)
-AddValaCFlagIfSupported(-Wno-unused-variable)
-AddValaCFlagIfSupported(-Wno-unused-function)
-AddValaCFlagIfSupported(-Wno-unused-label)
+if (NOT ("all" IN_LIST VALA_WARN OR "conversion" IN_LIST VALA_WARN))
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-int-conversion)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-pointer-sign)
+ AddCFlagIfSupported(VALA_CFLAGS -Wno-incompatible-pointer-types)
+endif ()
try_compile(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
if (NOT __WITHOUT_FILE_OFFSET_BITS_64)
try_compile(__WITH_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
if (__WITH_FILE_OFFSET_BITS_64)
- AddCFlagIfSupported(-D_FILE_OFFSET_BITS=64)
- AddValaCFlagIfSupported(-D_FILE_OFFSET_BITS=64)
+ AddCFlagIfSupported(CMAKE_C_FLAGS -D_FILE_OFFSET_BITS=64)
message(STATUS "Enabled large file support using _FILE_OFFSET_BITS=64")
else (__WITH_FILE_OFFSET_BITS_64)
message(STATUS "Large file support not available")