Reduce third-part warnings a better way.

Thanks to Kevin Kofler for pointing out what I'd forgotten about
source-file flags. While at it, introduce a generic mechanism for
suppressing warnings in third-party code.

Mostly reverts 4930484931
This commit is contained in:
Adriaan de Groot 2017-09-19 16:46:55 +02:00
parent b04a890798
commit 0c129f2460
2 changed files with 16 additions and 25 deletions

View File

@ -65,6 +65,13 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
endforeach()
# Third-party code where we don't care so much about compiler warnings
# (because it's uncomfortable to patch) get different flags; use
# set_source_files_properties( <file>
# PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" )
# to switch off warnings for those sources.
set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" )
set( CMAKE_CXX_FLAGS_DEBUG "-g" )
set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG" )
@ -76,6 +83,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" )
set( SUPPRESS_3RDPARTY_WARNINGS "" )
endif()
if( CMAKE_COMPILER_IS_GNUCXX )

View File

@ -19,14 +19,6 @@ set( libSources
JobQueue.cpp
ProcessJob.cpp
)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
# Build subdirs as their own separate OBJECT libraries,
# to allow changing compiler warnings on their code.
set( utilsSources
utils/CalamaresUtils.cpp
utils/CalamaresUtilsSystem.cpp
@ -34,26 +26,19 @@ set( utilsSources
utils/PluginFactory.cpp
utils/Retranslator.cpp
)
add_library( utilsLib OBJECT ${utilsSources} )
target_compile_options( utilsLib PUBLIC -fPIC )
target_include_directories( utilsLib PUBLIC
$<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES>
)
set_target_properties( utilsLib PROPERTIES AUTOMOC TRUE )
set( kdsagSources
kdsingleapplicationguard/kdsingleapplicationguard.cpp
kdsingleapplicationguard/kdsharedmemorylocker.cpp
kdsingleapplicationguard/kdtoolsglobal.cpp
kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp
)
add_library( kdsagLib OBJECT ${kdsagSources} )
target_compile_options( kdsagLib PUBLIC -fPIC )
target_include_directories( kdsagLib PUBLIC
$<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES>
)
set_target_properties( kdsagLib PROPERTIES AUTOMOC TRUE )
set_source_files_properties( ${kdsagSources}
PROPERTIES COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}" )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
if( WITH_PYTHON )
set( libSources
@ -91,10 +76,7 @@ if( WITH_PYTHONQT )
endif()
add_library( calamares SHARED ${libSources}
$<TARGET_OBJECTS:kdsagLib>
$<TARGET_OBJECTS:utilsLib>
)
add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} )
set_target_properties( calamares
PROPERTIES
AUTOMOC TRUE