| @@ -0,0 +1 @@ | |||||
| # This file is generated by cmake for dependency checking of the CMakeCache.txt file | |||||
| @@ -20,7 +20,8 @@ EndIf ( ) | |||||
| # Project ######################################################################################### | # Project ######################################################################################### | ||||
| Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-var.cmake" ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-options.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-var.cmake ) | |||||
| Project ( cppcore | Project ( cppcore | ||||
| DESCRIPTION "A simple library" | DESCRIPTION "A simple library" | ||||
| VERSION "${CPPCORE_VERSION}" ) | VERSION "${CPPCORE_VERSION}" ) | ||||
| @@ -41,9 +42,12 @@ Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-c | |||||
| @ONLY ) | @ONLY ) | ||||
| Set ( ConfigPackageLocation "${CPPCORE_INSTALL_DIR_SHARE}/cmake" ) | Set ( ConfigPackageLocation "${CPPCORE_INSTALL_DIR_SHARE}/cmake" ) | ||||
| Install ( EXPORT cppcore | |||||
| NAMESPACE cppcore:: | |||||
| DESTINATION ${ConfigPackageLocation} ) | |||||
| Install ( EXPORT | |||||
| cppcore | |||||
| NAMESPACE | |||||
| cppcore:: | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} ) | |||||
| Install ( FILES | Install ( FILES | ||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config.cmake" | "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config.cmake" | ||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" | "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" | ||||
| @@ -1,4 +1,6 @@ | |||||
| # cppcore-config.cmake - package configuration file | # cppcore-config.cmake - package configuration file | ||||
| Get_Filename_Component ( CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) | |||||
| Include ( ${CURRENT_DIR}/cppcore.cmake ) | |||||
| Include ( FindPackageHandleStandardArgs ) | |||||
| Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) | |||||
| Find_Package_Handle_Standard_Args ( cppcore CONFIG_MODE ) | |||||
| Include ( "${CMAKE_CURRENT_LIST_DIR}/cppcore.cmake") | |||||
| @@ -0,0 +1,6 @@ | |||||
| Option ( CPPCORE_INSTALL_HEADER | |||||
| "Install headers of cppcore." | |||||
| ON ) | |||||
| Option ( CPPCORE_USE_GIT_VERSION | |||||
| "Read the git tags to get the version of cppcore" | |||||
| ON ) | |||||
| @@ -1,20 +1,44 @@ | |||||
| # Version | # Version | ||||
| Set ( CPPCORE_VERSION_MAJOR 1 ) | |||||
| Set ( CPPCORE_VERSION_MINOR 0 ) | |||||
| Set ( CPPCORE_VERSION_PATCH 0 ) | |||||
| Set ( CPPCORE_VERSION_BUILD 0 ) | |||||
| Set ( CPPCORE_VERSION_SHORT "${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}" ) | |||||
| Set ( CPPCORE_VERSION "${CPPCORE_VERSION_SHORT}.${CPPCORE_VERSION_PATCH}.${CPPCORE_VERSION_BUILD}" ) | |||||
| Set ( CPPCORE_NAME "cppcore-${CPPCORE_VERSION_SHORT}" ) | |||||
| Set ( CPPCORE_OUTPUTNAME "helloworld" ) | |||||
| Set ( CPPCORE_VERSION_MAJOR 1 ) | |||||
| Set ( CPPCORE_VERSION_MINOR 0 ) | |||||
| Set ( CPPCORE_VERSION_PATCH 0 ) | |||||
| Set ( CPPCORE_VERSION_BUILD 0 ) | |||||
| Set ( CPPCORE_VERSION_HASH "" ) | |||||
| Set ( CPPCORE_VERSION_BEHIND 0 ) | |||||
| Set ( CPPCORE_VERSION_DIRTY 0 ) | |||||
| # Git Version | |||||
| If ( CPPCORE_USE_GIT_VERSION ) | |||||
| Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
| If ( HAS_GIT_HELPER ) | |||||
| GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
| CPPCORE_VERSION_MAJOR | |||||
| CPPCORE_VERSION_MINOR | |||||
| CPPCORE_VERSION_PATCH | |||||
| CPPCORE_VERSION_BUILD | |||||
| CPPCORE_VERSION_HASH | |||||
| CPPCORE_VERSION_BEHIND | |||||
| CPPCORE_VERSION_DIRTY ) | |||||
| EndIf ( ) | |||||
| EndIf ( ) | |||||
| # Strings | |||||
| Set ( CPPCORE_VERSION_SHORT "${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}" ) | |||||
| Set ( CPPCORE_VERSION "${CPPCORE_VERSION_SHORT}.${CPPCORE_VERSION_PATCH}.${CPPCORE_VERSION_BUILD}" ) | |||||
| Set ( CPPCORE_VERSION_COMPLETE "${CPPCORE_VERSION}" ) | |||||
| Set ( CPPCORE_NAME "cppcore-${CPPCORE_VERSION_SHORT}" ) | |||||
| Set ( CPPCORE_OUTPUTNAME "cppcore" ) | |||||
| If ( CPPCORE_VERSION_BEHIND ) | |||||
| Set ( CPPCORE_VERSION_COMPLETE "${CPPCORE_VERSION_COMPLETE}+${CPPCORE_VERSION_BEHIND}" ) | |||||
| EndIf ( ) | |||||
| # Install directories | # Install directories | ||||
| Set ( CPPCORE_INSTALL_DIR_INCLUDE "include/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_LIB "lib" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_SHARE "share/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_INCLUDE "include/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_LIB "lib" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_SHARE "share/${CPPCORE_NAME}" ) | |||||
| # C Standard | # 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 | |||||
| @@ -31,7 +31,7 @@ namespace cppcore | |||||
| _buffer = std::forward<T_vector>(v); | _buffer = std::forward<T_vector>(v); | ||||
| auto beg = reinterpret_cast<char_type*>(&_buffer.front()); | auto beg = reinterpret_cast<char_type*>(&_buffer.front()); | ||||
| auto end = beg + _buffer.size(); | auto end = beg + _buffer.size(); | ||||
| this->setp(beg, end); | |||||
| this->setp(end, end); | |||||
| this->setg(beg, beg, end); | this->setg(beg, beg, end); | ||||
| } | } | ||||
| @@ -53,8 +53,8 @@ namespace cppcore | |||||
| ::underflow() | ::underflow() | ||||
| { | { | ||||
| auto gpos = static_cast<size_t>(this->gptr() - this->eback()); | auto gpos = static_cast<size_t>(this->gptr() - this->eback()); | ||||
| this->setg(this->pbase(), this->pbase() + gpos, this->pptr()); | |||||
| if (this->gptr() == this->pptr()) | |||||
| this->setg(this->eback(), this->eback() + gpos, this->pptr()); | |||||
| if (this->gptr() == this->egptr()) | |||||
| return traits_type::eof(); | return traits_type::eof(); | ||||
| auto ret = static_cast<int_type>(*this->gptr()); | auto ret = static_cast<int_type>(*this->gptr()); | ||||
| return ret; | return ret; | ||||
| @@ -16,10 +16,12 @@ Target_Include_Directories ( cppcore | |||||
| # Install ######################################################################################### | # Install ######################################################################################### | ||||
| # Header | # Header | ||||
| Install ( FILES ${CPPCORE_INCLUDE_DIR}/cppcore.h | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppcore | |||||
| EXPORT cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| If ( CPPCORE_INSTALL_HEADER ) | |||||
| Install ( FILES ${CPPCORE_INCLUDE_DIR}/cppcore.h | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppcore | |||||
| EXPORT cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| EndIf ( ) | |||||
| @@ -11,34 +11,47 @@ If ( NOT "${GTest_FOUND}" ) | |||||
| Return ( ) | Return ( ) | ||||
| EndIf ( ) | EndIf ( ) | ||||
| File ( GLOB_RECURSE CPPCORE_TEST_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
| File ( GLOB_RECURSE CPPCORE_TEST_INLINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
| File ( GLOB_RECURSE CPPCORE_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| Add_Executable ( cppcore-test | |||||
| EXCLUDE_FROM_ALL | |||||
| ${CPPCORE_TEST_HEADER_FILES} | |||||
| ${CPPCORE_TEST_INLINE_FILES} | |||||
| ${CPPCORE_TEST_SOURCE_FILES} ) | |||||
| Target_Link_Libraries ( cppcore-test | |||||
| PUBLIC | |||||
| cppcore | |||||
| GTest::Main ) | |||||
| # optimization | |||||
| If ( HAS_COTIRE ) | |||||
| Cotire ( cppcore-test ) | |||||
| EndIf ( ) | |||||
| # pedantic | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( cppcore-test | |||||
| ALL ) | |||||
| EndIf ( ) | |||||
| # test | |||||
| If ( HAS_CMAKE_TESTS ) | |||||
| Add_CMake_Test ( NAME cppcore TARGET cppcore-test ) | |||||
| Else ( ) | |||||
| Add_Test ( NAME cppcore COMMAND cppcore-test ) | |||||
| EndIf ( ) | |||||
| File ( GLOB_RECURSE CPPCORE_TEST_HEADER_FILES | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
| File ( GLOB_RECURSE CPPCORE_TEST_INLINE_FILES | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
| File ( GLOB_RECURSE CPPCORE_TEST_SOURCE_FILES | |||||
| RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| ForEach ( FILE IN LISTS CPPCORE_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 | |||||
| ${CPPCORE_TEST_HEADER_FILES} | |||||
| ${CPPCORE_TEST_INLINE_FILES} | |||||
| ${FILE} ) | |||||
| Target_Link_Libraries ( ${TEST_NAME} | |||||
| PUBLIC | |||||
| cppcore | |||||
| GTest::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 ( ) | |||||