From 994baa43aec99fdbe79df98f5cf8d98a2d727fab Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Tue, 3 Aug 2021 23:05:47 +0200 Subject: Add ENABLE_WERROR CMake option --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 634bd55..d72cae2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set(ABI_VERSION 0) # Options option(ENABLE_TESTS "Enable all tests and checks" OFF) option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF) +option(ENABLE_WERROR "Treat all build warnings as errors" OFF) if(ENABLE_COVERAGE) set(ENABLE_TESTS ON) @@ -22,6 +23,10 @@ else() set(CMAKE_BUILD_TYPE "Release") endif() +if(ENABLE_WERROR) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() # GNU standard installation directories include (GNUInstallDirs) @@ -68,3 +73,4 @@ endif() message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") message(STATUS "Unit tests: ${ENABLE_TESTS}") +message(STATUS "Build with -Werror: ${ENABLE_WERROR}") -- cgit v1.2.3 From 81325279efcc1ae8826a3cb3909db4d1ae13ee28 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 4 Aug 2021 12:15:18 +0200 Subject: .build.yml: Add -DENABLE_WERROR=ON build option (for cmake based builds). --- .build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.build.yml b/.build.yml index ac45e68..dfdb693 100644 --- a/.build.yml +++ b/.build.yml @@ -105,9 +105,9 @@ build_scripts: - scan-build $CHECKERS ./configure --prefix=/usr --enable-gtk-doc --enable-compile-warnings=maximum - elif [ -e ./CMakeLists.txt ]; then - if [ ${DISTRO_NAME} == "debian" ];then - - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON + - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DENABLE_WERROR=ON - else - - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON + - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_WERROR=ON - fi - else - exit 1 -- cgit v1.2.3 From 84d2a71f5c8c5efddb86ab311e1ab0ac5a7e910e Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 4 Aug 2021 12:34:27 +0200 Subject: tests/CMakeLists.txt: Drop -no-pie from CXX_FLAGS and add it as a target link option. --- tests/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4fa6602..0349ae6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,5 @@ find_package(GMock) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie") - # gschemas.compiled set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "gschemas.compiled") @@ -21,6 +19,7 @@ add_custom_target("gschemas-compiled" ALL DEPENDS "gschemas.compiled") add_executable(tst_utils tst_utils.cpp) target_compile_definitions(tst_utils PUBLIC SCHEMA_DIR="${CMAKE_CURRENT_BINARY_DIR}") +target_link_options(tst_utils PRIVATE -no-pie) add_dependencies(tst_utils "gschemas-compiled") target_include_directories(tst_utils PUBLIC "${CMAKE_SOURCE_DIR}/src") -- cgit v1.2.3