diff --git a/cmake/KDBindingsConfig.h.in b/cmake/KDBindingsConfig.h.in new file mode 100644 index 0000000..df8e60c --- /dev/null +++ b/cmake/KDBindingsConfig.h.in @@ -0,0 +1,10 @@ +#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 +#define KDBINDINGS_WARN_UNUSED +#endif diff --git a/src/kdbindings/CMakeLists.txt b/src/kdbindings/CMakeLists.txt index ac7c610..9bef8f1 100644 --- a/src/kdbindings/CMakeLists.txt +++ b/src/kdbindings/CMakeLists.txt @@ -6,6 +6,13 @@ # 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" +) + set(HEADERS binding.h binding_evaluator.h @@ -36,6 +43,7 @@ set_target_properties(KDBindings PROPERTIES target_include_directories(KDBindings INTERFACE $ $ + $ # Include the build directory for the configured header ) if(KDBindings_ERROR_ON_WARNING) if(MSVC) diff --git a/src/kdbindings/signal.h b/src/kdbindings/signal.h index dade00c..aaf2b03 100644 --- a/src/kdbindings/signal.h +++ b/src/kdbindings/signal.h @@ -11,11 +11,6 @@ #pragma once -// Enables compiler warnings for unused ConnectionHandle results. -#ifndef KDBINDINGS_WARN_UNUSED -#define KDBINDINGS_WARN_UNUSED [[nodiscard]] -#endif - #include #include #include @@ -26,6 +21,8 @@ #include #include +#include + /** * @brief The main namespace of the KDBindings library. *