Browse Source

* refactored cmake structure

master
Erik Junghanns 6 years ago
parent
commit
452450f4b4
48 changed files with 26 additions and 128 deletions
  1. +7
    -1
      CMakeLists.txt
  2. +0
    -0
      include/cpputils/container/handle_manager.h
  3. +0
    -0
      include/cpputils/container/nullable.h
  4. +0
    -0
      include/cpputils/container/smart_ptr.h
  5. +0
    -0
      include/cpputils/container/wrapper.h
  6. +0
    -0
      include/cpputils/logging/consumer.h
  7. +0
    -0
      include/cpputils/logging/consumer/consumer.h
  8. +0
    -0
      include/cpputils/logging/consumer/consumer_stream.h
  9. +0
    -0
      include/cpputils/logging/global.h
  10. +0
    -0
      include/cpputils/logging/logger.h
  11. +0
    -0
      include/cpputils/logging/logger_impl.h
  12. +0
    -0
      include/cpputils/logging/matcher.h
  13. +0
    -0
      include/cpputils/logging/matcher/matcher.h
  14. +0
    -0
      include/cpputils/logging/matcher/matcher_all.h
  15. +0
    -0
      include/cpputils/logging/matcher/matcher_default.h
  16. +0
    -0
      include/cpputils/logging/matcher/matcher_regex.h
  17. +0
    -0
      include/cpputils/logging/rule.h
  18. +0
    -0
      include/cpputils/logging/types.h
  19. +0
    -0
      include/cpputils/misc/convert.h
  20. +0
    -0
      include/cpputils/misc/enum.h
  21. +0
    -0
      include/cpputils/misc/exception.h
  22. +0
    -0
      include/cpputils/misc/flags.h
  23. +0
    -0
      include/cpputils/misc/indent.h
  24. +0
    -0
      include/cpputils/misc/linq.h
  25. +0
    -0
      include/cpputils/misc/misc.h
  26. +0
    -0
      include/cpputils/misc/stream.h
  27. +0
    -0
      include/cpputils/misc/string.h
  28. +0
    -0
      include/cpputils/misc/time.h
  29. +0
    -0
      include/cpputils/misc/transform_iterator.h
  30. +0
    -0
      include/cpputils/misc/type_helper.h
  31. +0
    -0
      include/cpputils/mp.h
  32. +0
    -0
      include/cpputils/mp/core.h
  33. +0
    -0
      include/cpputils/mp/core/array.h
  34. +0
    -0
      include/cpputils/mp/core/checker.h
  35. +0
    -0
      include/cpputils/mp/core/conditionals.h
  36. +0
    -0
      include/cpputils/mp/core/const.h
  37. +0
    -0
      include/cpputils/mp/core/modifier.h
  38. +0
    -0
      include/cpputils/mp/core/types.h
  39. +0
    -0
      include/cpputils/mp/core/when.h
  40. +5
    -6
      src/CMakeLists.txt
  41. +0
    -119
      src/impl/logging/LoggerImpl.cpp.old
  42. +0
    -0
      src/logging/consumer/consumer.cpp
  43. +0
    -0
      src/logging/consumer/consumer_stream.cpp
  44. +0
    -0
      src/logging/global.cpp
  45. +0
    -0
      src/logging/logger.cpp
  46. +0
    -0
      src/logging/logger_impl.cpp
  47. +0
    -0
      src/logging/matcher.cpp
  48. +14
    -2
      test/CMakeLists.txt

+ 7
- 1
CMakeLists.txt View File

@@ -5,10 +5,16 @@ If ( NOT CMAKE_BUILD_TYPE )
EndIf ( NOT CMAKE_BUILD_TYPE )

CMake_Minimum_Required ( VERSION 3.5.1 FATAL_ERROR )
Set ( CMAKE_CXX_STANDARD 14 )
Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../../inc/cmake/")
Include ( GlobalCompilerFlags OPTIONAL )
Include ( cotire OPTIONAL )

# Tests ###########################################################################################

Include ( CTest )
Enable_Testing ( )

# Projects ########################################################################################

Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src )


src/cpputils/container/handle_manager.h → include/cpputils/container/handle_manager.h View File


src/cpputils/container/nullable.h → include/cpputils/container/nullable.h View File


src/cpputils/container/smart_ptr.h → include/cpputils/container/smart_ptr.h View File


src/cpputils/container/wrapper.h → include/cpputils/container/wrapper.h View File


src/cpputils/logging/consumer.h → include/cpputils/logging/consumer.h View File


src/cpputils/logging/consumer/consumer.h → include/cpputils/logging/consumer/consumer.h View File


src/cpputils/logging/consumer/consumer_stream.h → include/cpputils/logging/consumer/consumer_stream.h View File


src/cpputils/logging/global.h → include/cpputils/logging/global.h View File


src/cpputils/logging/logger.h → include/cpputils/logging/logger.h View File


src/cpputils/logging/logger_impl.h → include/cpputils/logging/logger_impl.h View File


src/cpputils/logging/matcher.h → include/cpputils/logging/matcher.h View File


src/cpputils/logging/matcher/matcher.h → include/cpputils/logging/matcher/matcher.h View File


src/cpputils/logging/matcher/matcher_all.h → include/cpputils/logging/matcher/matcher_all.h View File


src/cpputils/logging/matcher/matcher_default.h → include/cpputils/logging/matcher/matcher_default.h View File


src/cpputils/logging/matcher/matcher_regex.h → include/cpputils/logging/matcher/matcher_regex.h View File


src/cpputils/logging/rule.h → include/cpputils/logging/rule.h View File


src/cpputils/logging/types.h → include/cpputils/logging/types.h View File


src/cpputils/misc/convert.h → include/cpputils/misc/convert.h View File


src/cpputils/misc/enum.h → include/cpputils/misc/enum.h View File


src/cpputils/misc/exception.h → include/cpputils/misc/exception.h View File


src/cpputils/misc/flags.h → include/cpputils/misc/flags.h View File


src/cpputils/misc/indent.h → include/cpputils/misc/indent.h View File


src/cpputils/misc/linq.h → include/cpputils/misc/linq.h View File


src/cpputils/misc/misc.h → include/cpputils/misc/misc.h View File


src/cpputils/misc/stream.h → include/cpputils/misc/stream.h View File


src/cpputils/misc/string.h → include/cpputils/misc/string.h View File


src/cpputils/misc/time.h → include/cpputils/misc/time.h View File


src/cpputils/misc/transform_iterator.h → include/cpputils/misc/transform_iterator.h View File


src/cpputils/misc/type_helper.h → include/cpputils/misc/type_helper.h View File


src/cpputils/mp.h → include/cpputils/mp.h View File


src/cpputils/mp/core.h → include/cpputils/mp/core.h View File


src/cpputils/mp/core/array.h → include/cpputils/mp/core/array.h View File


src/cpputils/mp/core/checker.h → include/cpputils/mp/core/checker.h View File


src/cpputils/mp/core/conditionals.h → include/cpputils/mp/core/conditionals.h View File


src/cpputils/mp/core/const.h → include/cpputils/mp/core/const.h View File


src/cpputils/mp/core/modifier.h → include/cpputils/mp/core/modifier.h View File


src/cpputils/mp/core/types.h → include/cpputils/mp/core/types.h View File


src/cpputils/mp/core/when.h → include/cpputils/mp/core/when.h View File


+ 5
- 6
src/CMakeLists.txt View File

@@ -1,13 +1,12 @@
# Project: cpputils ###############################################################################

Project ( cpputils )
File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/impl/*.cpp )
Add_Library ( cpputils STATIC ${SOURCE_FILES} )
Include_Directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
Project ( cpputils VERSION 1.0.0.0 LANGUAGES CXX )
File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp )
Add_Library ( cpputils ${SOURCE_FILES} )
Target_Include_Directories (
cpputils
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include
)
If ( __COTIRE_INCLUDED )
Cotire ( cpputils )
EndIf ( )
EndIf ( )

+ 0
- 119
src/impl/logging/LoggerImpl.cpp.old View File

@@ -1,119 +0,0 @@
#include <list>
#include <iomanip>

#include "cpputils/logger_impl.h"

using namespace logging;

std::string EmptyString;

consumer::consumer(const std::string& n, bool autoRegister) :
_name(n)
{
if (autoRegister)
register_consumer(*this);
}

consumer::~consumer()
{ unregister_consumer(*this); }

void consumer_stream::log(data_ptr_s data)
{
std::lock_guard<std::mutex> lk(_mutex);

using namespace std;
if (!data)
return;
auto& d = *data;
auto t = std::chrono::duration_cast<std::chrono::duration<double, std::ratio<1>>>(d.time.time_since_epoch()).count();
auto f = d.file;
if (f)
{
auto tmp = strrchr(f, '/');
if (tmp)
f = tmp + 1;
}
else
f = "unknown";

StreamFormatSaver formatSaver(*_stream);
if (t >= 0) *_stream << "[" << fixed << setfill(' ') << setw(17) << setprecision(6) << t << "] ";
switch(d.level)
{
case level::Debug: *_stream << "DEBUG "; break;
case level::Info: *_stream << "INFO "; break;
case level::Warn: *_stream << "WARN "; break;
case level::Error: *_stream << "ERROR "; break;
}

if (d.sender) *_stream << "0x" << hex << setw(2 * sizeof(void*)) << setfill('0') << d.sender;
else *_stream << " ";
if (d.thread != std::thread::id()) *_stream << "@" << hex << setw(2 * sizeof(void*)) << setfill('0') << d.thread;
else *_stream << " ";
if (!d.name.empty()) *_stream << " '" << d.name << "'";
if (d.line) *_stream << " - " << setw(25) << setfill(' ') << f << ":" << setw(5) << setfill(' ') << dec << d.line;
if (!d.message.empty())
{
*_stream << ": " << d.message;
if (d.message.back() != '\n')
*_stream << std::endl;
}
else
*_stream << std::endl;
}



bool matcher_all::match(const logger& logger) const
{ return true; }

bool matcher_all::match(const consumer& consumer) const
{ return true; }

bool matcher_regex::match(const logger& logger) const
{ return !logger.name().empty() && std::regex_match(logger.name(), _regex) != _invert; }

bool matcher_regex::match(const consumer& consumer) const
{ return !consumer.name().empty() && std::regex_match(consumer.name(), _regex) != _invert; }

bool matcher_default::match(const logger& logger) const
{ return &_defaultLogger == &logger; }




const std::string& logger::name() const
{ return EmptyString; }

bool logger::is_enabled(level level) const
{ return false; }

void logger::log(data_ptr_s data) const
{ /* no op */ }



const std::string& logger_impl::name() const
{ return _name; }

bool logger_impl::is_enabled(level level) const
{
for (auto& rule : _rules)
{
if (rule->is_enabled(level))
return true;
}
return false;
}

void logger_impl::log(data_ptr_s data) const
{
std::lock_guard<std::mutex> lk(_mutex);
for (auto& r : _rules)
r->log(data);
}

namespace logging
{
}

src/impl/logging/consumer/consumer.cpp → src/logging/consumer/consumer.cpp View File


src/impl/logging/consumer/consumer_stream.cpp → src/logging/consumer/consumer_stream.cpp View File


src/impl/logging/global.cpp → src/logging/global.cpp View File


src/impl/logging/logger.cpp → src/logging/logger.cpp View File


src/impl/logging/logger_impl.cpp → src/logging/logger_impl.cpp View File


src/impl/logging/matcher.cpp → src/logging/matcher.cpp View File


+ 14
- 2
test/CMakeLists.txt View File

@@ -15,9 +15,21 @@ Target_Link_Libraries (
pthread
)

Add_Custom_Target ( run_test_cpputils DEPENDS test_cpputils COMMAND ./test_cpputils )
# Build Tests #####################################################################################

If ( NOT TARGET build_tests)
Add_Custom_Target ( build_tests )
EndIf ( )
Add_Dependencies ( build_tests test_cpputils )

# Run Tests #######################################################################################

If ( NOT TARGET tests)
Add_Custom_Target ( tests )
EndIf ( )
Add_Dependencies ( tests run_test_cpputils )
Add_Custom_Target ( run_test_cpputils DEPENDS test_cpputils COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cpputils )
Add_Dependencies ( tests run_test_cpputils )

# CTest ###########################################################################################

Add_Test ( NAME cpputils COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cpputils )

Loading…
Cancel
Save