From 6aa358577e071704c2536a5279655890d449bc14 Mon Sep 17 00:00:00 2001 From: Shivam Kunwar Date: Wed, 5 Jun 2024 11:13:29 +0530 Subject: [PATCH] move preprocessor macros directly in a standard header file --- src/kdbindings/CMakeLists.txt | 14 +++++++------- .../kdbindings/KDBindingsConfig.h | 3 --- src/kdbindings/signal.h | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) rename cmake/KDBindingsConfig.h.in => src/kdbindings/KDBindingsConfig.h (58%) diff --git a/src/kdbindings/CMakeLists.txt b/src/kdbindings/CMakeLists.txt index 9bef8f1..42d4acf 100644 --- a/src/kdbindings/CMakeLists.txt +++ b/src/kdbindings/CMakeLists.txt @@ -6,12 +6,7 @@ # Contact KDAB at for commercial licensing options. # -option(KDBINDINGS_ENABLE_WARN_UNUSED "Enable warnings for unused ConnectionHandles" OFF) - -configure_file( - "${PROJECT_SOURCE_DIR}/cmake/KDBindingsConfig.h.in" - "${CMAKE_BINARY_DIR}/include/KDBindingsConfig.h" -) +option(KDBINDINGS_ENABLE_WARN_UNUSED "Enable warnings for unused ConnectionHandles" ON) set(HEADERS binding.h @@ -27,6 +22,7 @@ set(HEADERS connection_evaluator.h connection_handle.h utils.h + KDBindingsConfig.h ) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0") @@ -40,10 +36,14 @@ add_library(KDAB::KDBindings ALIAS KDBindings) set_target_properties(KDBindings PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17 ) + +if(KDBINDINGS_ENABLE_WARN_UNUSED) + target_compile_definitions(KDBindings INTERFACE KDBINDINGS_ENABLE_WARN_UNUSED=1) +endif() + target_include_directories(KDBindings INTERFACE $ $ - $ # Include the build directory for the configured header ) if(KDBindings_ERROR_ON_WARNING) if(MSVC) diff --git a/cmake/KDBindingsConfig.h.in b/src/kdbindings/KDBindingsConfig.h similarity index 58% rename from cmake/KDBindingsConfig.h.in rename to src/kdbindings/KDBindingsConfig.h index df8e60c..a6f694b 100644 --- a/cmake/KDBindingsConfig.h.in +++ b/src/kdbindings/KDBindingsConfig.h @@ -1,8 +1,5 @@ #pragma once -// Check if KDBINDINGS_ENABLE_WARN_UNUSED option is set -#cmakedefine KDBINDINGS_ENABLE_WARN_UNUSED - #ifdef KDBINDINGS_ENABLE_WARN_UNUSED #define KDBINDINGS_WARN_UNUSED [[nodiscard]] #else diff --git a/src/kdbindings/signal.h b/src/kdbindings/signal.h index aaf2b03..4e07bbb 100644 --- a/src/kdbindings/signal.h +++ b/src/kdbindings/signal.h @@ -11,6 +11,7 @@ #pragma once + #include #include #include @@ -21,7 +22,7 @@ #include #include -#include +#include /** * @brief The main namespace of the KDBindings library.