| @@ -20,18 +20,25 @@ EndIf ( ) | |||||
| # Project ######################################################################################### | # Project ######################################################################################### | ||||
| Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-var.cmake" ) | |||||
| Project ( cppargs | |||||
| DESCRIPTION "A simple library" | |||||
| VERSION "${CPPARGS_VERSION}" ) | |||||
| Include ( CTest ) | Include ( CTest ) | ||||
| Include ( GNUInstallDirs ) | Include ( GNUInstallDirs ) | ||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-options.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-const.cmake ) | |||||
| Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-var.cmake ) | |||||
| Project ( ${CPPARGS_PROJECT_NAME} | |||||
| DESCRIPTION "${CPPARGS_PROJECT_DESCRIPTION}" | |||||
| VERSION "${CPPARGS_VERSION}" ) | |||||
| # 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 CPPARGS_HAS_EXPORT | |||||
| OR NOT CPPARGS_INSTALL_PACKAGE ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Include ( CMakePackageConfigHelpers ) | Include ( CMakePackageConfigHelpers ) | ||||
| Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config-version.cmake" | Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config-version.cmake" | ||||
| VERSION ${CPPARGS_VERSION} | VERSION ${CPPARGS_VERSION} | ||||
| @@ -1,8 +1,7 @@ | |||||
| # cppargs-config.cmake - package configuration file | # cppargs-config.cmake - package configuration file | ||||
| Message ( WARNING "Please configure the dependencies of this package!" ) | |||||
| # Include ( CMakeFindDependencyMacro ) | |||||
| # Find_Dependency ( <dependency> ) | |||||
| Include ( CMakeFindDependencyMacro ) | |||||
| Find_Dependency ( cppcore ) | |||||
| Include ( FindPackageHandleStandardArgs ) | Include ( FindPackageHandleStandardArgs ) | ||||
| Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) | Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) | ||||
| @@ -0,0 +1,28 @@ | |||||
| # This file contains constant variables that are fixed to this project | |||||
| # Version | |||||
| Set ( CPPARGS_VERSION_MAJOR 1 ) | |||||
| Set ( CPPARGS_VERSION_MINOR 0 ) | |||||
| Set ( CPPARGS_VERSION_PATCH 0 ) | |||||
| Set ( CPPARGS_VERSION_BUILD 0 ) | |||||
| Set ( CPPARGS_VERSION_HASH "" ) | |||||
| Set ( CPPARGS_VERSION_BEHIND 0 ) | |||||
| Set ( CPPARGS_VERSION_DIRTY 0 ) | |||||
| # Names | |||||
| Set ( CPPARGS_PROJECT_NAME "cppargs" ) | |||||
| Set ( CPPARGS_PROJECT_DESCRIPTION "Library to parse command line arguments." ) | |||||
| # Include generated variables for further usage | |||||
| Include ( ${CMAKE_CURRENT_LIST_DIR}/cppargs-var.cmake ) | |||||
| # Install directories | |||||
| Set ( CPPARGS_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPARGS_NAME}" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${CPPARGS_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 ) | |||||
| @@ -0,0 +1,11 @@ | |||||
| # This file contains options that can be passed to the cmake command | |||||
| Option ( CPPARGS_INSTALL_HEADER | |||||
| "Install headers of cppargs." | |||||
| ON ) | |||||
| Option ( CPPARGS_INSTALL_PACKAGE | |||||
| "Install the cmake package of cppargs." | |||||
| ON ) | |||||
| Option ( CPPARGS_USE_GIT_VERSION | |||||
| "Read the git tags to get the version of cppargs" | |||||
| ON ) | |||||
| @@ -1,20 +1,26 @@ | |||||
| # Version | |||||
| Set ( CPPARGS_VERSION_MAJOR 1 ) | |||||
| Set ( CPPARGS_VERSION_MINOR 0 ) | |||||
| Set ( CPPARGS_VERSION_PATCH 0 ) | |||||
| Set ( CPPARGS_VERSION_BUILD 0 ) | |||||
| Set ( CPPARGS_VERSION_SHORT "${CPPARGS_VERSION_MAJOR}.${CPPARGS_VERSION_MINOR}" ) | |||||
| Set ( CPPARGS_VERSION "${CPPARGS_VERSION_SHORT}.${CPPARGS_VERSION_PATCH}.${CPPARGS_VERSION_BUILD}" ) | |||||
| Set ( CPPARGS_NAME "cppargs-${CPPARGS_VERSION_SHORT}" ) | |||||
| Set ( CPPARGS_OUTPUTNAME "cppargs" ) | |||||
| # This file contains generated variables that are needed for the project | |||||
| # Install directories | |||||
| Set ( CPPARGS_INSTALL_DIR_INCLUDE "include/${CPPARGS_NAME}" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_LIB "lib" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_SHARE "share/${CPPARGS_NAME}" ) | |||||
| # Git Version | |||||
| If ( CPPARGS_USE_GIT_VERSION ) | |||||
| Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
| If ( HAS_GIT_HELPER ) | |||||
| GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
| CPPARGS_VERSION_MAJOR | |||||
| CPPARGS_VERSION_MINOR | |||||
| CPPARGS_VERSION_PATCH | |||||
| CPPARGS_VERSION_BUILD | |||||
| CPPARGS_VERSION_HASH | |||||
| CPPARGS_VERSION_BEHIND | |||||
| CPPARGS_VERSION_DIRTY ) | |||||
| EndIf ( ) | |||||
| EndIf ( ) | |||||
| # C Standard | |||||
| Set ( CMAKE_C_STANDARD 11 ) | |||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
| Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
| # Strings | |||||
| Set ( CPPARGS_VERSION_SHORT "${CPPARGS_VERSION_MAJOR}.${CPPARGS_VERSION_MINOR}" ) | |||||
| Set ( CPPARGS_VERSION "${CPPARGS_VERSION_SHORT}.${CPPARGS_VERSION_PATCH}.${CPPARGS_VERSION_BUILD}" ) | |||||
| Set ( CPPARGS_VERSION_COMPLETE "${CPPARGS_VERSION}" ) | |||||
| Set ( CPPARGS_NAME "${CPPARGS_PROJECT_NAME}-${CPPARGS_VERSION_SHORT}" ) | |||||
| Set ( CPPARGS_OUTPUTNAME "${CPPARGS_PROJECT_NAME}" ) | |||||
| If ( CPPARGS_VERSION_BEHIND ) | |||||
| Set ( CPPARGS_VERSION_COMPLETE "${CPPARGS_VERSION_COMPLETE}+${CPPARGS_VERSION_BEHIND}" ) | |||||
| EndIf ( ) | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit 1a32531aef2deeebd5637b1873bc4e976628801c | |||||
| Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b | |||||
| @@ -20,11 +20,16 @@ Target_Link_Libraries ( cppargs | |||||
| # Install ######################################################################################### | # Install ######################################################################################### | ||||
| Set ( CPPARGS_HAS_EXPORT False PARENT_SCOPE ) | |||||
| # Header | # Header | ||||
| Install ( FILES ${CPPARGS_INCLUDE_DIR}/cppargs.h | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPARGS_INCLUDE_DIR}/cppargs | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppargs | |||||
| EXPORT cppargs | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| If ( CPPARGS_INSTALL_HEADER ) | |||||
| Set ( CPPARGS_HAS_EXPORT True PARENT_SCOPE ) | |||||
| Install ( FILES ${CPPARGS_INCLUDE_DIR}/cppargs.h | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPARGS_INCLUDE_DIR}/cppargs | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppargs | |||||
| EXPORT cppargs | |||||
| DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) | |||||
| EndIf ( ) | |||||
| @@ -11,34 +11,42 @@ If ( NOT "${GTest_FOUND}" ) | |||||
| Return ( ) | Return ( ) | ||||
| EndIf ( ) | EndIf ( ) | ||||
| File ( GLOB_RECURSE CPPARGS_TEST_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_INLINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| Add_Executable ( cppargs-test | |||||
| EXCLUDE_FROM_ALL | |||||
| ${CPPARGS_TEST_HEADER_FILES} | |||||
| ${CPPARGS_TEST_INLINE_FILES} | |||||
| ${CPPARGS_TEST_SOURCE_FILES} ) | |||||
| Target_Link_Libraries ( cppargs-test | |||||
| PUBLIC | |||||
| cppargs | |||||
| GTest::Main ) | |||||
| # optimization | |||||
| If ( HAS_COTIRE ) | |||||
| Cotire ( cppargs-test ) | |||||
| EndIf ( ) | |||||
| # pedantic | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( cppargs-test | |||||
| ALL ) | |||||
| EndIf ( ) | |||||
| # test | |||||
| If ( HAS_CMAKE_TESTS ) | |||||
| Add_CMake_Test ( NAME cppargs TARGET cppargs-test ) | |||||
| Else ( ) | |||||
| Add_Test ( NAME cppargs COMMAND cppargs-test ) | |||||
| EndIf ( ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_HEADER_FILES | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_INLINE_FILES | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_SOURCE_FILES | |||||
| RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| ForEach ( FILE IN LISTS CPPARGS_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 | |||||
| ${CPPARGS_TEST_HEADER_FILES} | |||||
| ${CPPARGS_TEST_INLINE_FILES} | |||||
| ${FILE} ) | |||||
| Target_Link_Libraries ( ${TEST_NAME} | |||||
| PUBLIC | |||||
| cppargs | |||||
| GTest::Main ) | |||||
| # pedantic | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
| 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 ( ) | |||||