From 0c129f2460683815b0704696c9e5f0f465235e07 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:46:55 +0200 Subject: [PATCH] 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 49304849318241258ae7159cf38f32b708fe63c2 --- CMakeLists.txt | 9 +++++++++ src/libcalamares/CMakeLists.txt | 32 +++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0a3c3e4..da33793c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( + # 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 ) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index c97e35ada..ba10fcc70 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -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 - $ -) -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 - $ -) -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} - $ - $ -) +add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} ) set_target_properties( calamares PROPERTIES AUTOMOC TRUE