Clang: be more explicit about marking third-party code.

- This is only a partial solution to warnings caused by third-party
   code, since #including the headers from other sources won't apply
   the warning-suppressions.
 - Flags are not applied when building the source as part of a larger
   target, but are on re-building just one object (it seems -- CMake
   issue to track down).
This commit is contained in:
Adriaan de Groot 2017-09-21 04:53:09 -04:00
parent d89b17a244
commit 40c49bd50d
3 changed files with 20 additions and 6 deletions

View File

@ -67,8 +67,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
# Third-party code where we don't care so much about compiler warnings # Third-party code where we don't care so much about compiler warnings
# (because it's uncomfortable to patch) get different flags; use # (because it's uncomfortable to patch) get different flags; use
# set_source_files_properties( <file> # mark_thirdparty_code( <file> [<file>...] )
# PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" )
# to switch off warnings for those sources. # to switch off warnings for those sources.
set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" ) set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" )
@ -87,6 +86,14 @@ else()
set( SUPPRESS_3RDPARTY_WARNINGS "" ) set( SUPPRESS_3RDPARTY_WARNINGS "" )
endif() endif()
macro(mark_thirdparty_code)
set_source_files_properties( ${ARGV}
PROPERTIES
COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}"
COMPILE_DEFINITIONS "THIRDPARTY"
)
endmacro()
if( CMAKE_COMPILER_IS_GNUCXX ) if( CMAKE_COMPILER_IS_GNUCXX )
if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9 ) CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9 )

View File

@ -32,8 +32,7 @@ set( kdsagSources
kdsingleapplicationguard/kdtoolsglobal.cpp kdsingleapplicationguard/kdtoolsglobal.cpp
kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp
) )
set_source_files_properties( ${kdsagSources} mark_thirdparty_code( ${kdsagSources} )
PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" )
include_directories( include_directories(
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}

View File

@ -1,6 +1,6 @@
project( libcalamaresui CXX ) project( libcalamaresui CXX )
list( APPEND calamaresui_SOURCES set( calamaresui_SOURCES
modulesystem/CppJobModule.cpp modulesystem/CppJobModule.cpp
modulesystem/Module.cpp modulesystem/Module.cpp
modulesystem/ModuleManager.cpp modulesystem/ModuleManager.cpp
@ -29,7 +29,15 @@ list( APPEND calamaresui_SOURCES
ViewManager.cpp ViewManager.cpp
) )
list( APPEND calamaresui_UI # Don't warn about third-party sources
mark_thirdparty_code(
utils/ImageRegistry.cpp
utils/qjsonitem.cpp
utils/qjsonmodel.cpp
widgets/waitingspinnerwidget.cpp
)
set( calamaresui_UI
utils/DebugWindow.ui utils/DebugWindow.ui
) )