Skip to content

Commit

Permalink
Merge pull request #3 from aiosadchy/consistent-build-options
Browse files Browse the repository at this point in the history
Consistent CMake options
  • Loading branch information
aiosadchy authored Mar 22, 2021
2 parents f85adcb + ee856a5 commit 30c22a2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion include/utl/concatenate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/utl/non_constructible.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
~Type() = delete;


#ifdef UTL_UNSCOPED_MACROS
#ifndef UTL_NO_UNSCOPED_MACROS

#define NON_CONSTRUCTIBLE(Type) \
Type() = delete; \
Expand Down
2 changes: 1 addition & 1 deletion include/utl/non_copyable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
2 changes: 1 addition & 1 deletion include/utl/repeat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion include/utl/scope_guard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [&]()
Expand Down
2 changes: 1 addition & 1 deletion include/utl/static_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)


#ifdef UTL_UNSCOPED_MACROS
#ifndef UTL_NO_UNSCOPED_MACROS

#define STATIC_BLOCK \
UTL_STATIC_BLOCK_IMPL( \
Expand Down
6 changes: 3 additions & 3 deletions include/utl/unique_identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 30c22a2

Please sign in to comment.