From ee856a5d96717dc386e88e071846d58fe6a08321 Mon Sep 17 00:00:00 2001 From: Alexander Osadchy Date: Tue, 23 Mar 2021 02:08:29 +0300 Subject: [PATCH] Make default values of build options consistent with potential non-cmake usage --- CMakeLists.txt | 20 ++++++++++---------- include/utl/concatenate.hpp | 2 +- include/utl/non_constructible.hpp | 2 +- include/utl/non_copyable.hpp | 2 +- include/utl/repeat.hpp | 2 +- include/utl/scope_guard.hpp | 2 +- include/utl/static_block.hpp | 2 +- include/utl/unique_identifier.hpp | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e10c539..3b6fb00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,14 +15,14 @@ project(utl ################################################################################ option( - UTL_UNSCOPED_MACROS - "Define macros without 'UTL' prefix" + UTL_NO_UNSCOPED_MACROS + "Do not re-define library macros without 'UTL' prefix" OFF ) option( - UTL_USE_COUNTER_MACRO - "Allow use of '__COUNTER__' macro in library code" + UTL_DO_NOT_USE_COUNTER_MACRO + "Do not allow use of '__COUNTER__' macro in library code" OFF ) @@ -47,14 +47,14 @@ function(msg level) message(${level} "utl: " ${ARGN}) endfunction() -if (UTL_UNSCOPED_MACROS) - set(UTL_COMPILE_DEFINITIONS ${UTL_COMPILE_DEFINITIONS} UTL_UNSCOPED_MACROS) - msg(STATUS "define unscoped macros") +if (UTL_NO_UNSCOPED_MACROS) + set(UTL_COMPILE_DEFINITIONS ${UTL_COMPILE_DEFINITIONS} UTL_NO_UNSCOPED_MACROS) + msg(STATUS "unscoped macros are disabled") endif() -if (UTL_USE_COUNTER_MACRO) - set(UTL_COMPILE_DEFINITIONS ${UTL_COMPILE_DEFINITIONS} UTL_USE_COUNTER_MACRO) - msg(STATUS "allow using '__COUNTER__' macro in library code") +if (UTL_DO_NOT_USE_COUNTER_MACRO) + set(UTL_COMPILE_DEFINITIONS ${UTL_COMPILE_DEFINITIONS} UTL_DO_NOT_USE_COUNTER_MACRO) + msg(STATUS "do not allow use of '__COUNTER__' macro in library code") endif() target_compile_definitions(utl INTERFACE ${UTL_COMPILE_DEFINITIONS}) diff --git a/include/utl/concatenate.hpp b/include/utl/concatenate.hpp index 2b5b6d3..ae6da99 100644 --- a/include/utl/concatenate.hpp +++ b/include/utl/concatenate.hpp @@ -8,7 +8,7 @@ UTL_CONCATENATE_WITHOUT_EXPANSION(x, y) -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define CONCATENATE_WITHOUT_EXPANSION(x, y) \ x ## y diff --git a/include/utl/non_constructible.hpp b/include/utl/non_constructible.hpp index c941d51..9e96bc0 100644 --- a/include/utl/non_constructible.hpp +++ b/include/utl/non_constructible.hpp @@ -6,7 +6,7 @@ ~Type() = delete; -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define NON_CONSTRUCTIBLE(Type) \ Type() = delete; \ diff --git a/include/utl/non_copyable.hpp b/include/utl/non_copyable.hpp index 7773cd7..78dbb4b 100644 --- a/include/utl/non_copyable.hpp +++ b/include/utl/non_copyable.hpp @@ -6,7 +6,7 @@ Type &operator=(const Type &another) = delete; -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define NON_COPYABLE(Type) \ Type(const Type &another) = delete; \ diff --git a/include/utl/repeat.hpp b/include/utl/repeat.hpp index 70d55d8..422414c 100644 --- a/include/utl/repeat.hpp +++ b/include/utl/repeat.hpp @@ -8,7 +8,7 @@ for ([[maybe_unused]] auto UTL_UNIQUE_IDENTIFIER : utl::Range(count)) -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define REPEAT(count) \ for ([[maybe_unused]] auto UTL_UNIQUE_IDENTIFIER : utl::Range(count)) diff --git a/include/utl/scope_guard.hpp b/include/utl/scope_guard.hpp index 994ee89..105de1f 100644 --- a/include/utl/scope_guard.hpp +++ b/include/utl/scope_guard.hpp @@ -31,7 +31,7 @@ class ScopeGuard { [[maybe_unused]] utl::ScopeGuard UTL_UNIQUE_IDENTIFIER = [&]() -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define SCOPE_GUARD \ [[maybe_unused]] utl::ScopeGuard UTL_UNIQUE_IDENTIFIER = [&]() diff --git a/include/utl/static_block.hpp b/include/utl/static_block.hpp index 875c186..7b5fdab 100644 --- a/include/utl/static_block.hpp +++ b/include/utl/static_block.hpp @@ -16,7 +16,7 @@ ) -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS #define STATIC_BLOCK \ UTL_STATIC_BLOCK_IMPL( \ diff --git a/include/utl/unique_identifier.hpp b/include/utl/unique_identifier.hpp index 1dd0894..f47dbce 100644 --- a/include/utl/unique_identifier.hpp +++ b/include/utl/unique_identifier.hpp @@ -3,7 +3,7 @@ #include "utl/concatenate.hpp" -#if defined(UTL_USE_COUNTER_MACRO) && defined(__COUNTER__) +#if !defined(UTL_DO_NOT_USE_COUNTER_MACRO) && defined(__COUNTER__) #define UTL_UNIQUE_IDENTIFIER \ UTL_CONCATENATE(utl_unique_identifier_, __COUNTER__) #else @@ -12,9 +12,9 @@ #endif -#ifdef UTL_UNSCOPED_MACROS +#ifndef UTL_NO_UNSCOPED_MACROS - #if defined(UTL_USE_COUNTER_MACRO) && defined(__COUNTER__) + #if !defined(UTL_DO_NOT_USE_COUNTER_MACRO) && defined(__COUNTER__) #define UNIQUE_IDENTIFIER \ UTL_CONCATENATE(utl_unique_identifier_, __COUNTER__) #else