| @@ -1,3 +1,3 @@ | |||||
| [submodule "cmake/modules"] | [submodule "cmake/modules"] | ||||
| path = cmake/modules | path = cmake/modules | ||||
| url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git | |||||
| url = b3rgmann@git.bergmann89.de:cpp/CMakeModules.git | |||||
| @@ -1,63 +1,63 @@ | |||||
| # Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
| CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
| CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
| # Set CMAKE_BUILD_TYPE | # Set CMAKE_BUILD_TYPE | ||||
| If ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
| EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
| If ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
| EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
| # Set CMAKE_MODULE_PATH | # Set CMAKE_MODULE_PATH | ||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| EndIf ( ) | |||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
| EndIf ( ) | |||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| EndIf ( ) | |||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
| EndIf ( ) | |||||
| # Project ######################################################################################### | # Project ######################################################################################### | ||||
| Include ( CTest ) | |||||
| Include ( GNUInstallDirs ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-options.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-const.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-var.cmake ) | |||||
| Project ( ${CPPCORE_PROJECT_NAME} | |||||
| DESCRIPTION "${CPPCORE_PROJECT_DESCRIPTION}" | |||||
| VERSION "${CPPCORE_VERSION}" ) | |||||
| Include ( GNUInstallDirs ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-options.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-const.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-var.cmake ) | |||||
| Project ( ${CPPCORE_PROJECT_NAME} | |||||
| DESCRIPTION "${CPPCORE_PROJECT_DESCRIPTION}" | |||||
| VERSION "${CPPCORE_VERSION}" ) | |||||
| Include ( CTest ) | |||||
| # Subdirectories | # Subdirectories | ||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
| # Install | # Install | ||||
| If ( NOT CPPCORE_HAS_EXPORT | |||||
| OR NOT CPPCORE_INSTALL_PACKAGE ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Include ( CMakePackageConfigHelpers ) | |||||
| Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" | |||||
| VERSION ${CPPCORE_VERSION} | |||||
| COMPATIBILITY AnyNewerVersion ) | |||||
| Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-config.cmake" | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config.cmake" | |||||
| @ONLY ) | |||||
| Set ( ConfigPackageLocation "${CPPCORE_INSTALL_DIR_SHARE}/cmake" ) | |||||
| Install ( EXPORT | |||||
| cppcore | |||||
| NAMESPACE | |||||
| cppcore:: | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} ) | |||||
| Install ( FILES | |||||
| If ( NOT CPPCORE_HAS_EXPORT | |||||
| OR NOT CPPCORE_INSTALL_PACKAGE ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Include ( CMakePackageConfigHelpers ) | |||||
| Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" | |||||
| VERSION ${CPPCORE_VERSION} | |||||
| COMPATIBILITY AnyNewerVersion ) | |||||
| Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-config.cmake" | |||||
| "${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" | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} | |||||
| COMPONENT | |||||
| Devel ) | |||||
| @ONLY ) | |||||
| Set ( ConfigPackageLocation "${CPPCORE_INSTALL_DIR_SHARE}/cmake" ) | |||||
| Install ( EXPORT | |||||
| cppcore | |||||
| NAMESPACE | |||||
| cppcore:: | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} ) | |||||
| Install ( FILES | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config.cmake" | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} | |||||
| COMPONENT | |||||
| Devel ) | |||||
| @@ -0,0 +1,3 @@ | |||||
| # cppcore | |||||
| C++ library with usefull helper classes. | |||||
| @@ -1,28 +1,28 @@ | |||||
| # This file contains constant variables that are fixed to this project | # This file contains constant variables that are fixed to this project | ||||
| # 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_HASH "" ) | |||||
| Set ( CPPCORE_VERSION_BEHIND 0 ) | |||||
| Set ( CPPCORE_VERSION_DIRTY 0 ) | |||||
| 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 ) | |||||
| # Names | # Names | ||||
| Set ( CPPCORE_PROJECT_NAME "cppcore" ) | |||||
| Set ( CPPCORE_PROJECT_DESCRIPTION "C++ core library" ) | |||||
| Set ( CPPCORE_PROJECT_NAME "cppcore" ) | |||||
| Set ( CPPCORE_PROJECT_DESCRIPTION "C++ core library" ) | |||||
| # Include generated variables for further usage | # Include generated variables for further usage | ||||
| Include ( ${CMAKE_CURRENT_LIST_DIR}/cppcore-var.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_LIST_DIR}/cppcore-var.cmake ) | |||||
| # Install directories | # Install directories | ||||
| Set ( CPPCORE_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPCORE_NAME}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
| Set ( CPPCORE_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${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,17 +1,17 @@ | |||||
| # This file contains options that can be passed to the cmake command | # This file contains options that can be passed to the cmake command | ||||
| Option ( CPPCORE_INSTALL_HEADER | |||||
| "Install headers of cppcore." | |||||
| ON ) | |||||
| Option ( CPPCORE_INSTALL_PACKAGE | |||||
| "Install the cmake package of cppcore." | |||||
| ON ) | |||||
| Option ( CPPCORE_USE_GIT_VERSION | |||||
| "Read the git tags to get the version of cppcore" | |||||
| ON ) | |||||
| If ( NOT CPPCORE_CONVERT_CAST ) | |||||
| Set ( CPPCORE_CONVERT_CAST throw | |||||
| CACHE STRING "Specify how the convert_cast should handle invalid values." ) | |||||
| Set_Property ( CACHE CPPCORE_CONVERT_CAST | |||||
| PROPERTY STRINGS throw abort ) | |||||
| EndIf ( ) | |||||
| Option ( CPPCORE_INSTALL_HEADER | |||||
| "Install headers of cppcore." | |||||
| ON ) | |||||
| Option ( CPPCORE_INSTALL_PACKAGE | |||||
| "Install the cmake package of cppcore." | |||||
| ON ) | |||||
| Option ( CPPCORE_USE_GIT_VERSION | |||||
| "Read the git tags to get the version of cppcore" | |||||
| ON ) | |||||
| If ( NOT CPPCORE_CONVERT_CAST ) | |||||
| Set ( CPPCORE_CONVERT_CAST throw | |||||
| CACHE STRING "Specify how the convert_cast should handle invalid values." ) | |||||
| Set_Property ( CACHE CPPCORE_CONVERT_CAST | |||||
| PROPERTY STRINGS throw abort ) | |||||
| EndIf ( ) | |||||
| @@ -1,26 +1,32 @@ | |||||
| # This file contains generated variables that are needed for the project | # This file contains generated variables that are needed for the project | ||||
| # Git Version | # 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 ( ) | |||||
| 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 | # 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_PROJECT_NAME}-${CPPCORE_VERSION_SHORT}" ) | |||||
| Set ( CPPCORE_OUTPUTNAME "${CPPCORE_PROJECT_NAME}" ) | |||||
| If ( CPPCORE_VERSION_BEHIND ) | |||||
| Set ( CPPCORE_VERSION_COMPLETE "${CPPCORE_VERSION_COMPLETE}+${CPPCORE_VERSION_BEHIND}" ) | |||||
| EndIf ( ) | |||||
| 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_PROJECT_NAME}-${CPPCORE_VERSION_SHORT}" ) | |||||
| Set ( CPPCORE_OUTPUTNAME | |||||
| "${CPPCORE_PROJECT_NAME}" ) | |||||
| If ( CPPCORE_VERSION_BEHIND ) | |||||
| Set ( CPPCORE_VERSION_COMPLETE | |||||
| "${CPPCORE_VERSION_COMPLETE}+${CPPCORE_VERSION_BEHIND}" ) | |||||
| EndIf ( ) | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b | |||||
| Subproject commit 94b9877d65e46c9d8169ebc46f163d02e4d9dcf3 | |||||
| @@ -1,42 +1,42 @@ | |||||
| # Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
| Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
| Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
| Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
| Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
| # Interface Library ############################################################################### | # Interface Library ############################################################################### | ||||
| If ( "${CPPCORE_CONVERT_CAST}" STREQUAL "abort" ) | |||||
| Set ( CPPCORE_CONVERT_CAST_ABORT 1 ) | |||||
| ElseIf ( "${CPPCORE_CONVERT_CAST}" STREQUAL "throw" ) | |||||
| Set ( CPPCORE_CONVERT_CAST_THROW 1 ) | |||||
| EndIf ( ) | |||||
| If ( "${CPPCORE_CONVERT_CAST}" STREQUAL "abort" ) | |||||
| Set ( CPPCORE_CONVERT_CAST_ABORT 1 ) | |||||
| ElseIf ( "${CPPCORE_CONVERT_CAST}" STREQUAL "throw" ) | |||||
| Set ( CPPCORE_CONVERT_CAST_THROW 1 ) | |||||
| EndIf ( ) | |||||
| Set ( CPPCORE_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated ) | |||||
| Configure_File ( ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/config.h.in | |||||
| ${CPPCORE_GENERATED_INCLUDE_DIR}/cppcore/config.h ) | |||||
| Set ( CPPCORE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
| Add_Library ( cppcore INTERFACE ) | |||||
| Target_Include_Directories ( cppcore | |||||
| INTERFACE | |||||
| $<BUILD_INTERFACE:${CPPCORE_INCLUDE_DIR}> | |||||
| $<BUILD_INTERFACE:${CPPCORE_GENERATED_INCLUDE_DIR}> | |||||
| $<INSTALL_INTERFACE:${CPPCORE_INSTALL_DIR_INCLUDE}> ) | |||||
| Set ( CPPCORE_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated ) | |||||
| Configure_File ( ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/config.h.in | |||||
| ${CPPCORE_GENERATED_INCLUDE_DIR}/cppcore/config.h ) | |||||
| Set ( CPPCORE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
| Add_Library ( cppcore INTERFACE ) | |||||
| Target_Include_Directories ( cppcore | |||||
| INTERFACE | |||||
| $<BUILD_INTERFACE:${CPPCORE_INCLUDE_DIR}> | |||||
| $<BUILD_INTERFACE:${CPPCORE_GENERATED_INCLUDE_DIR}> | |||||
| $<INSTALL_INTERFACE:${CPPCORE_INSTALL_DIR_INCLUDE}> ) | |||||
| # Install ######################################################################################### | # Install ######################################################################################### | ||||
| Set ( CPPCORE_HAS_EXPORT False PARENT_SCOPE ) | |||||
| Set ( CPPCORE_HAS_EXPORT False PARENT_SCOPE ) | |||||
| # Header | # Header | ||||
| If ( CPPCORE_INSTALL_HEADER ) | |||||
| Set ( CPPCORE_HAS_EXPORT True PARENT_SCOPE ) | |||||
| Install ( FILES ${CPPCORE_INCLUDE_DIR}/cppcore.h | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_GENERATED_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppcore | |||||
| EXPORT cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| EndIf ( ) | |||||
| If ( CPPCORE_INSTALL_HEADER ) | |||||
| Set ( CPPCORE_HAS_EXPORT True PARENT_SCOPE ) | |||||
| Install ( FILES ${CPPCORE_INCLUDE_DIR}/cppcore.h | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPCORE_GENERATED_INCLUDE_DIR}/cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppcore | |||||
| EXPORT cppcore | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| EndIf ( ) | |||||
| @@ -1,52 +1,59 @@ | |||||
| # Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
| Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
| Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
| Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
| Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
| Find_Package ( Sanitizers QUIET ) | |||||
| # Test ############################################################################################ | # Test ############################################################################################ | ||||
| Find_Package ( GTest ) | |||||
| If ( NOT "${GTest_FOUND}" ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Find_Package ( GTest ) | |||||
| If ( NOT "${GTest_FOUND}" ) | |||||
| Return ( ) | |||||
| 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 ) | |||||
| 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 ) | |||||
| ForEach ( FILE IN LISTS CPPCORE_TEST_SOURCE_FILES ) | |||||
| # add test | # 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 ) | |||||
| 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 ) | |||||
| # Sanitizers | |||||
| If ( Sanitizers_FOUND ) | |||||
| Add_Sanitizers ( ${TEST_NAME} ) | |||||
| EndIf ( ) | |||||
| # pedantic | # pedantic | ||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
| EndIf ( ) | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
| EndIf ( ) | |||||
| # test | # test | ||||
| If ( HAS_CMAKE_TESTS ) | |||||
| Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppcore ) | |||||
| Else ( ) | |||||
| Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
| EndIf ( ) | |||||
| EndForEach ( ) | |||||
| If ( HAS_CMAKE_TESTS ) | |||||
| Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppcore ) | |||||
| Else ( ) | |||||
| Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
| EndIf ( ) | |||||
| EndForEach ( ) | |||||