| @@ -1,3 +1,3 @@ | |||
| [submodule "/home/bergmann/projects/TotoStarOnline/projects/worker/cpplogging/cmake/modules"] | |||
| path = /home/bergmann/projects/TotoStarOnline/projects/worker/cpplogging/cmake/modules | |||
| [submodule "cmake/modules"] | |||
| path = cmake/modules | |||
| url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git | |||
| @@ -20,7 +20,8 @@ EndIf ( ) | |||
| # Project ######################################################################################### | |||
| Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-var.cmake" ) | |||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-options.cmake ) | |||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpplogging-var.cmake ) | |||
| Project ( cpplogging | |||
| DESCRIPTION "A simple library" | |||
| VERSION "${CPPLOGGING_VERSION}" ) | |||
| @@ -41,9 +42,12 @@ Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpploggin | |||
| @ONLY ) | |||
| Set ( ConfigPackageLocation "${CPPLOGGING_INSTALL_DIR_SHARE}/cmake" ) | |||
| Install ( EXPORT cpplogging | |||
| NAMESPACE cpplogging:: | |||
| DESTINATION ${ConfigPackageLocation} ) | |||
| Install ( EXPORT | |||
| cpplogging | |||
| NAMESPACE | |||
| cpplogging:: | |||
| DESTINATION | |||
| ${ConfigPackageLocation} ) | |||
| Install ( FILES | |||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cpplogging-config.cmake" | |||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cpplogging-config-version.cmake" | |||
| @@ -1,7 +1,6 @@ | |||
| # cpplogging-config.cmake - package configuration file | |||
| Get_Filename_Component ( CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) | |||
| Include ( ${CURRENT_DIR}/cpplogging.cmake ) | |||
| Include ( CMakeFindDependencyMacro ) | |||
| Find_Dependency ( cppcore ) | |||
| Include ( FindPackageHandleStandardArgs ) | |||
| Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) | |||
| Find_Package_Handle_Standard_Args ( cpplogging CONFIG_MODE ) | |||
| Include ( "${CMAKE_CURRENT_LIST_DIR}/cpplogging.cmake") | |||
| @@ -0,0 +1,18 @@ | |||
| Option ( CPPLOGGING_INSTALL_HEADER | |||
| "Install headers of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_STATIC | |||
| "Install static library of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_SHARED | |||
| "Install shared library of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_DEBUG | |||
| "Install the stripped debug informations of cpplogging." | |||
| OFF ) | |||
| Option ( CPPLOGGING_NO_STRIP | |||
| "Do not strip debug symbols from binary." | |||
| OFF ) | |||
| Option ( CPPLOGGING_USE_GIT_VERSION | |||
| "Read the git tags to get the version of cpplogging" | |||
| ON ) | |||
| @@ -1,20 +1,44 @@ | |||
| # Version | |||
| Set ( CPPLOGGING_VERSION_MAJOR 1 ) | |||
| Set ( CPPLOGGING_VERSION_MINOR 0 ) | |||
| Set ( CPPLOGGING_VERSION_PATCH 0 ) | |||
| Set ( CPPLOGGING_VERSION_BUILD 0 ) | |||
| Set ( CPPLOGGING_VERSION_SHORT "${CPPLOGGING_VERSION_MAJOR}.${CPPLOGGING_VERSION_MINOR}" ) | |||
| Set ( CPPLOGGING_VERSION "${CPPLOGGING_VERSION_SHORT}.${CPPLOGGING_VERSION_PATCH}.${CPPLOGGING_VERSION_BUILD}" ) | |||
| Set ( CPPLOGGING_NAME "cpplogging-${CPPLOGGING_VERSION_SHORT}" ) | |||
| Set ( CPPLOGGING_OUTPUTNAME "helloworld" ) | |||
| 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 ) | |||
| # Git Version | |||
| If ( CPPLOGGING_USE_GIT_VERSION ) | |||
| Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||
| If ( HAS_GIT_HELPER ) | |||
| GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||
| CPPLOGGING_VERSION_MAJOR | |||
| CPPLOGGING_VERSION_MINOR | |||
| CPPLOGGING_VERSION_PATCH | |||
| CPPLOGGING_VERSION_BUILD | |||
| CPPLOGGING_VERSION_HASH | |||
| CPPLOGGING_VERSION_BEHIND | |||
| CPPLOGGING_VERSION_DIRTY ) | |||
| EndIf ( ) | |||
| EndIf ( ) | |||
| # Strings | |||
| 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_COMPLETE "${CPPLOGGING_VERSION}" ) | |||
| Set ( CPPLOGGING_NAME "cpplogging-${CPPLOGGING_VERSION_SHORT}" ) | |||
| Set ( CPPLOGGING_OUTPUTNAME "cpplogging" ) | |||
| If ( CPPLOGGING_VERSION_BEHIND ) | |||
| Set ( CPPLOGGING_VERSION_COMPLETE "${CPPLOGGING_VERSION_COMPLETE}+${CPPLOGGING_VERSION_BEHIND}" ) | |||
| 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}" ) | |||
| 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 ) | |||
| 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 1a32531aef2deeebd5637b1873bc4e976628801c | |||
| Subproject commit 4953cd4cc849afdfa02a6057b5a2011fb62e91a6 | |||
| @@ -4,22 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE | |||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||
| Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||
| Option ( CPPLOGGING_INSTALL_HEADER | |||
| "Install headers of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_STATIC | |||
| "Install static library of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_SHARED | |||
| "Install shared library of cpplogging." | |||
| ON ) | |||
| Option ( CPPLOGGING_INSTALL_DEBUG | |||
| "Install the stripped debug informations of cpplogging." | |||
| OFF ) | |||
| Option ( CPPLOGGING_NO_STRIP | |||
| "Do not strip debug symbols from binary." | |||
| OFF ) | |||
| Find_Package ( nlohmann_json QUIET ) | |||
| If ( nlohmann_json_FOUND ) | |||
| Set ( CPPLOGGING_HAS_NLOHMANN_JSON true ) | |||
| @@ -56,7 +40,7 @@ Target_Include_Directories ( cpplogging-objects | |||
| Add_Library ( cpplogging-static STATIC $<TARGET_OBJECTS:cpplogging-objects> ) | |||
| Set_Target_Properties ( cpplogging-static | |||
| PROPERTIES | |||
| OUTPUT_NAME "cpplogging" | |||
| OUTPUT_NAME "${CPPLOGGING_OUTPUTNAME}" | |||
| VERSION ${CPPLOGGING_VERSION} ) | |||
| Target_Include_Directories ( cpplogging-static | |||
| PUBLIC | |||
| @@ -69,7 +53,7 @@ Target_Include_Directories ( cpplogging-static | |||
| Add_Library ( cpplogging-shared SHARED $<TARGET_OBJECTS:cpplogging-objects> ) | |||
| Set_Target_Properties ( cpplogging-shared | |||
| PROPERTIES | |||
| OUTPUT_NAME "cpplogging" | |||
| OUTPUT_NAME "${CPPLOGGING_OUTPUTNAME}" | |||
| VERSION ${CPPLOGGING_VERSION} | |||
| SOVERSION ${CPPLOGGING_VERSION_SHORT} ) | |||
| Target_Include_Directories ( cpplogging-shared | |||
| @@ -82,9 +66,9 @@ Target_Include_Directories ( cpplogging-shared | |||
| # pedantic | |||
| If ( HAS_PEDANTIC ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-objects CXX ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-static CXX ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-shared CXX ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-objects ALL ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-static ALL ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-shared ALL ) | |||
| EndIf ( ) | |||
| # cotire | |||
| @@ -11,33 +11,47 @@ If ( NOT "${GTest_FOUND}" ) | |||
| Return ( ) | |||
| EndIf ( ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_INLINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||
| Add_Executable ( cpplogging-test | |||
| EXCLUDE_FROM_ALL | |||
| ${CPPLOGGING_TEST_HEADER_FILES} | |||
| ${CPPLOGGING_TEST_INLINE_FILES} | |||
| ${CPPLOGGING_TEST_SOURCE_FILES} ) | |||
| Target_Link_Libraries ( cpplogging-test | |||
| PUBLIC | |||
| cpplogging-objects | |||
| GMock::Main ) | |||
| # pedantic | |||
| If ( HAS_PEDANTIC ) | |||
| Pedantic_Apply_Flags_Target ( cpplogging-test ALL ) | |||
| EndIf ( ) | |||
| # optimization | |||
| If ( HAS_COTIRE ) | |||
| Cotire ( cpplogging-test ) | |||
| EndIf ( ) | |||
| # test | |||
| If ( HAS_CMAKE_TESTS ) | |||
| Add_CMake_Test ( NAME cpplogging TARGET cpplogging-test ) | |||
| Else ( ) | |||
| Add_Test ( NAME cpplogging COMMAND cpplogging-test ) | |||
| EndIf ( ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_HEADER_FILES | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_INLINE_FILES | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||
| File ( GLOB_RECURSE CPPLOGGING_TEST_SOURCE_FILES | |||
| RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||
| ForEach ( FILE IN LISTS CPPLOGGING_TEST_SOURCE_FILES ) | |||
| # add test | |||
| Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||
| Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||
| Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||
| String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||
| String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||
| String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||
| Set ( TEST_NAME "test-${TEST_NAME}" ) | |||
| Add_Executable ( ${TEST_NAME} | |||
| EXCLUDE_FROM_ALL | |||
| ${CPPLOGGING_TEST_HEADER_FILES} | |||
| ${CPPLOGGING_TEST_INLINE_FILES} | |||
| ${FILE} ) | |||
| Target_Link_Libraries ( ${TEST_NAME} | |||
| PUBLIC | |||
| cpplogging-objects | |||
| GMock::Main ) | |||
| # pedantic | |||
| If ( HAS_PEDANTIC ) | |||
| Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||
| EndIf ( ) | |||
| # optimization | |||
| If ( HAS_COTIRE ) | |||
| Cotire ( ${TEST_NAME} ) | |||
| EndIf ( ) | |||
| # test | |||
| If ( HAS_CMAKE_TESTS ) | |||
| Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||
| Else ( ) | |||
| Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||
| EndIf ( ) | |||
| EndForEach ( ) | |||