| @@ -20,19 +20,25 @@ EndIf ( ) | |||||
| # Project ######################################################################################### | # Project ######################################################################################### | ||||
| Include ( CTest ) | |||||
| Include ( GNUInstallDirs ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-options.cmake ) | Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-options.cmake ) | ||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-const.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-var.cmake ) | Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-var.cmake ) | ||||
| Project ( cpplogging | |||||
| DESCRIPTION "A simple library" | |||||
| Project ( ${CPPLOGGING_PROJECT_NAME} | |||||
| DESCRIPTION "${CPPLOGGING_PROJECT_DESCRIPTION}" | |||||
| VERSION "${CPPLOGGING_VERSION}" ) | VERSION "${CPPLOGGING_VERSION}" ) | ||||
| Include ( CTest ) | |||||
| Include ( GNUInstallDirs ) | |||||
| # Subdirectories | # Subdirectories | ||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | ||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | ||||
| # Install | # Install | ||||
| If ( NOT CPPLOGGING_HAS_EXPORT | |||||
| OR NOT CPPLOGGING_INSTALL_PACKAGE ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Include ( CMakePackageConfigHelpers ) | Include ( CMakePackageConfigHelpers ) | ||||
| Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cpplogging-config-version.cmake" | Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cpplogging-config-version.cmake" | ||||
| VERSION ${CPPLOGGING_VERSION} | VERSION ${CPPLOGGING_VERSION} | ||||
| @@ -0,0 +1,28 @@ | |||||
| # This file contains constant variables that are fixed to this project | |||||
| # Version | |||||
| Set ( CPPLOGGING_VERSION_MAJOR 1 ) | |||||
| Set ( CPPLOGGING_VERSION_MINOR 0 ) | |||||
| Set ( CPPLOGGING_VERSION_PATCH 0 ) | |||||
| Set ( CPPLOGGING_VERSION_BUILD 0 ) | |||||
| Set ( CPPLOGGING_VERSION_HASH "" ) | |||||
| Set ( CPPLOGGING_VERSION_BEHIND 0 ) | |||||
| Set ( CPPLOGGING_VERSION_DIRTY 0 ) | |||||
| # Names | |||||
| Set ( CPPLOGGING_PROJECT_NAME "cpplogging" ) | |||||
| Set ( CPPLOGGING_PROJECT_DESCRIPTION "A simple hello world library" ) | |||||
| # Include generated variables for further usage | |||||
| Include ( ${CMAKE_CURRENT_LIST_DIR}/cpplogging-var.cmake ) | |||||
| # Install directories | |||||
| Set ( CPPLOGGING_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPLOGGING_NAME}" ) | |||||
| Set ( CPPLOGGING_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
| Set ( CPPLOGGING_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${CPPLOGGING_NAME}" ) | |||||
| # C Standard | |||||
| Set ( CMAKE_C_STANDARD 11 ) | |||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
| Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
| @@ -1,3 +1,5 @@ | |||||
| # This file contains options that can be passed to the cmake command | |||||
| Option ( CPPLOGGING_INSTALL_HEADER | Option ( CPPLOGGING_INSTALL_HEADER | ||||
| "Install headers of cpplogging." | "Install headers of cpplogging." | ||||
| ON ) | ON ) | ||||
| @@ -10,6 +12,9 @@ Option ( CPPLOGGING_INSTALL_SHARED | |||||
| Option ( CPPLOGGING_INSTALL_DEBUG | Option ( CPPLOGGING_INSTALL_DEBUG | ||||
| "Install the stripped debug informations of cpplogging." | "Install the stripped debug informations of cpplogging." | ||||
| OFF ) | OFF ) | ||||
| Option ( CPPLOGGING_INSTALL_PACKAGE | |||||
| "Install the cmake package of cpplogging." | |||||
| ON ) | |||||
| Option ( CPPLOGGING_NO_STRIP | Option ( CPPLOGGING_NO_STRIP | ||||
| "Do not strip debug symbols from binary." | "Do not strip debug symbols from binary." | ||||
| OFF ) | OFF ) | ||||
| @@ -1,11 +1,4 @@ | |||||
| # Version | |||||
| Set ( CPPLOGGING_VERSION_MAJOR 1 ) | |||||
| Set ( CPPLOGGING_VERSION_MINOR 0 ) | |||||
| Set ( CPPLOGGING_VERSION_PATCH 0 ) | |||||
| Set ( CPPLOGGING_VERSION_BUILD 0 ) | |||||
| Set ( CPPLOGGING_VERSION_HASH "" ) | |||||
| Set ( CPPLOGGING_VERSION_BEHIND 0 ) | |||||
| Set ( CPPLOGGING_VERSION_DIRTY 0 ) | |||||
| # This file contains generated variables that are needed for the project | |||||
| # Git Version | # Git Version | ||||
| If ( CPPLOGGING_USE_GIT_VERSION ) | If ( CPPLOGGING_USE_GIT_VERSION ) | ||||
| @@ -26,19 +19,8 @@ EndIf ( ) | |||||
| Set ( CPPLOGGING_VERSION_SHORT "${CPPLOGGING_VERSION_MAJOR}.${CPPLOGGING_VERSION_MINOR}" ) | Set ( CPPLOGGING_VERSION_SHORT "${CPPLOGGING_VERSION_MAJOR}.${CPPLOGGING_VERSION_MINOR}" ) | ||||
| Set ( CPPLOGGING_VERSION "${CPPLOGGING_VERSION_SHORT}.${CPPLOGGING_VERSION_PATCH}.${CPPLOGGING_VERSION_BUILD}" ) | Set ( CPPLOGGING_VERSION "${CPPLOGGING_VERSION_SHORT}.${CPPLOGGING_VERSION_PATCH}.${CPPLOGGING_VERSION_BUILD}" ) | ||||
| Set ( CPPLOGGING_VERSION_COMPLETE "${CPPLOGGING_VERSION}" ) | Set ( CPPLOGGING_VERSION_COMPLETE "${CPPLOGGING_VERSION}" ) | ||||
| Set ( CPPLOGGING_NAME "cpplogging-${CPPLOGGING_VERSION_SHORT}" ) | |||||
| Set ( CPPLOGGING_OUTPUTNAME "cpplogging" ) | |||||
| Set ( CPPLOGGING_NAME "${CPPLOGGING_PROJECT_NAME}-${CPPLOGGING_VERSION_SHORT}" ) | |||||
| Set ( CPPLOGGING_OUTPUTNAME "${CPPLOGGING_PROJECT_NAME}" ) | |||||
| If ( CPPLOGGING_VERSION_BEHIND ) | If ( CPPLOGGING_VERSION_BEHIND ) | ||||
| Set ( CPPLOGGING_VERSION_COMPLETE "${CPPLOGGING_VERSION_COMPLETE}+${CPPLOGGING_VERSION_BEHIND}" ) | Set ( CPPLOGGING_VERSION_COMPLETE "${CPPLOGGING_VERSION_COMPLETE}+${CPPLOGGING_VERSION_BEHIND}" ) | ||||
| EndIf ( ) | EndIf ( ) | ||||
| # Install directories | |||||
| Set ( CPPLOGGING_INSTALL_DIR_INCLUDE "include/${CPPLOGGING_NAME}" ) | |||||
| Set ( CPPLOGGING_INSTALL_DIR_LIB "lib" ) | |||||
| Set ( CPPLOGGING_INSTALL_DIR_SHARE "share/${CPPLOGGING_NAME}" ) | |||||
| # C Standard | |||||
| Set ( CMAKE_C_STANDARD 11 ) | |||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
| Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit 4953cd4cc849afdfa02a6057b5a2011fb62e91a6 | |||||
| Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b | |||||
| @@ -80,6 +80,8 @@ EndIf ( ) | |||||
| # Install ######################################################################################### | # Install ######################################################################################### | ||||
| Set ( CPPLOGGING_HAS_EXPORT False PARENT_SCOPE ) | |||||
| # Header | # Header | ||||
| If ( CPPLOGGING_INSTALL_HEADER ) | If ( CPPLOGGING_INSTALL_HEADER ) | ||||
| Install ( DIRECTORY ${CPPLOGGING_INCLUDE_DIR}/cpplogging | Install ( DIRECTORY ${CPPLOGGING_INCLUDE_DIR}/cpplogging | ||||
| @@ -90,6 +92,7 @@ EndIf ( ) | |||||
| # Static | # Static | ||||
| If ( CPPLOGGING_INSTALL_STATIC ) | If ( CPPLOGGING_INSTALL_STATIC ) | ||||
| Set ( CPPLOGGING_HAS_EXPORT True PARENT_SCOPE ) | |||||
| Install ( TARGETS cpplogging-static | Install ( TARGETS cpplogging-static | ||||
| EXPORT cpplogging | EXPORT cpplogging | ||||
| DESTINATION ${CPPLOGGING_INSTALL_DIR_LIB} ) | DESTINATION ${CPPLOGGING_INSTALL_DIR_LIB} ) | ||||
| @@ -97,6 +100,7 @@ EndIf ( ) | |||||
| # Shared | # Shared | ||||
| If ( CPPLOGGING_INSTALL_SHARED ) | If ( CPPLOGGING_INSTALL_SHARED ) | ||||
| Set ( CPPLOGGING_HAS_EXPORT True PARENT_SCOPE ) | |||||
| Install ( TARGETS cpplogging-shared | Install ( TARGETS cpplogging-shared | ||||
| EXPORT cpplogging | EXPORT cpplogging | ||||
| DESTINATION ${CPPLOGGING_INSTALL_DIR_LIB} ) | DESTINATION ${CPPLOGGING_INSTALL_DIR_LIB} ) | ||||
| @@ -43,11 +43,6 @@ ForEach ( FILE IN LISTS CPPLOGGING_TEST_SOURCE_FILES ) | |||||
| Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | ||||
| EndIf ( ) | EndIf ( ) | ||||
| # optimization | |||||
| If ( HAS_COTIRE ) | |||||
| Cotire ( ${TEST_NAME} ) | |||||
| EndIf ( ) | |||||
| # test | # test | ||||
| If ( HAS_CMAKE_TESTS ) | If ( HAS_CMAKE_TESTS ) | ||||
| Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | ||||
| @@ -1,6 +1,7 @@ | |||||
| #include <gtest/gtest.h> | #include <gtest/gtest.h> | ||||
| #include <gmock/gmock.h> | #include <gmock/gmock.h> | ||||
| #include <cpplogging/manager.h> | #include <cpplogging/manager.h> | ||||
| #include <cpplogging/interface.h> | |||||
| using namespace ::testing; | using namespace ::testing; | ||||
| using namespace ::cpplogging; | using namespace ::cpplogging; | ||||
| @@ -84,7 +85,7 @@ TEST(LoggingTests, matcher_regex) | |||||
| EXPECT_TRUE (matcher0.match(c0)); | EXPECT_TRUE (matcher0.match(c0)); | ||||
| EXPECT_FALSE(matcher0.match(c1)); | EXPECT_FALSE(matcher0.match(c1)); | ||||
| EXPECT_FALSE(matcher1.match(l0)); | |||||
| EXPECT_TRUE (matcher1.match(l0)); | |||||
| EXPECT_TRUE (matcher1.match(l1)); | EXPECT_TRUE (matcher1.match(l1)); | ||||
| } | } | ||||
| @@ -117,15 +118,15 @@ TEST(LoggingTests, log_base) | |||||
| auto& l0 = logger::get("logger0"); | auto& l0 = logger::get("logger0"); | ||||
| auto& l1 = logger::get("logger1"); | auto& l1 = logger::get("logger1"); | ||||
| cpplogging_log(l0, debug).sender((void*)0x11).message("test1") << " debug"; | |||||
| cpplogging_log(l0, info ).sender((void*)0x12).message("test1") << " info"; | |||||
| cpplogging_log(l0, warn ).sender((void*)0x13).message("test1") << " warn"; | |||||
| cpplogging_log(l0, error).sender((void*)0x14).message("test1") << " error"; | |||||
| cpplogging_log(l0, debug) << cpplogging::sender((void*)0x11) << "test1" << " debug"; | |||||
| cpplogging_log(l0, info ) << cpplogging::sender((void*)0x12) << "test1" << " info"; | |||||
| cpplogging_log(l0, warn ) << cpplogging::sender((void*)0x13) << "test1" << " warn"; | |||||
| cpplogging_log(l0, error) << cpplogging::sender((void*)0x14) << "test1" << " error"; | |||||
| cpplogging_log(l1, debug).sender((void*)0x21).message("test2") << " debug"; | |||||
| cpplogging_log(l1, info ).sender((void*)0x22).message("test2") << " info"; | |||||
| cpplogging_log(l1, warn ).sender((void*)0x23).message("test2") << " warn"; | |||||
| cpplogging_log(l1, error).sender((void*)0x24).message("test2") << " error"; | |||||
| cpplogging_log(l1, debug) << cpplogging::sender((void*)0x21) << "test2" << " debug"; | |||||
| cpplogging_log(l1, info ) << cpplogging::sender((void*)0x22) << "test2" << " info"; | |||||
| cpplogging_log(l1, warn ) << cpplogging::sender((void*)0x23) << "test2" << " warn"; | |||||
| cpplogging_log(l1, error) << cpplogging::sender((void*)0x24) << "test2" << " error"; | |||||
| } | } | ||||
| TEST(LoggingTests, log_inverted_regex) | TEST(LoggingTests, log_inverted_regex) | ||||
| @@ -150,9 +151,9 @@ TEST(LoggingTests, log_inverted_regex) | |||||
| auto& l1 = logger::get("logger1"); | auto& l1 = logger::get("logger1"); | ||||
| auto& l2 = logger::get("logger2"); | auto& l2 = logger::get("logger2"); | ||||
| cpplogging_log(l0, debug).sender((void*)0x10) << "test0"; | |||||
| cpplogging_log(l1, debug).sender((void*)0x11) << "test1"; | |||||
| cpplogging_log(l2, debug).sender((void*)0x12) << "test2"; | |||||
| cpplogging_log(l0, debug) << cpplogging::sender((void*)0x10) << "test0"; | |||||
| cpplogging_log(l1, debug) << cpplogging::sender((void*)0x11) << "test1"; | |||||
| cpplogging_log(l2, debug) << cpplogging::sender((void*)0x12) << "test2"; | |||||
| } | } | ||||
| #ifdef CPPLOGGING_HAS_LOAD_CONFIG | #ifdef CPPLOGGING_HAS_LOAD_CONFIG | ||||