diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d88b9c..4a60a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) EndIf ( ) -If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) +If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) diff --git a/projects/helloworld/cmake/helloworld-var.cmake b/projects/helloworld/cmake/helloworld-var.cmake index 6c96ccb..5878be7 100644 --- a/projects/helloworld/cmake/helloworld-var.cmake +++ b/projects/helloworld/cmake/helloworld-var.cmake @@ -15,3 +15,14 @@ Set ( CMAKE_C_STANDARD 11 ) Set ( CMAKE_CXX_STANDARD 17 ) Set ( CMAKE_C_STANDARD_REQUIRED ON ) Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) + +# Git Version +Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) +If ( HAS_GIT_HELPER ) + GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. + HELLOWORLD_VERSION_MAJOR + HELLOWORLD_VERSION_MINOR + HELLOWORLD_VERSION_PATCH + HELLOWORLD_VERSION_BUILD + HELLOWORLD_VERSION_HASH ) +EndIf ( ) diff --git a/projects/helloworld/test/CMakeLists.txt b/projects/helloworld/test/CMakeLists.txt index a7c0676..bb8442d 100644 --- a/projects/helloworld/test/CMakeLists.txt +++ b/projects/helloworld/test/CMakeLists.txt @@ -4,10 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) -If ( HAS_PEDANTIC ) - Pedantic_Apply_Flags ( ALL ) -EndIf ( ) - # Test ############################################################################################ Find_Package ( GTest ) diff --git a/projects/libhelloworld/CMakeLists.txt b/projects/libhelloworld/CMakeLists.txt index bdf10f5..a3e642c 100644 --- a/projects/libhelloworld/CMakeLists.txt +++ b/projects/libhelloworld/CMakeLists.txt @@ -41,9 +41,12 @@ Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhellow @ONLY ) Set ( ConfigPackageLocation "${LIBHELLOWORLD_INSTALL_DIR_SHARE}/cmake" ) -Install ( EXPORT libhelloworld - NAMESPACE libhelloworld:: - DESTINATION ${ConfigPackageLocation} ) +Install ( EXPORT + libhelloworld + NAMESPACE + libhelloworld:: + DESTINATION + ${ConfigPackageLocation} ) Install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config-version.cmake" diff --git a/projects/libhelloworld/cmake/libhelloworld-config.cmake b/projects/libhelloworld/cmake/libhelloworld-config.cmake index 9b88c09..a67ec90 100644 --- a/projects/libhelloworld/cmake/libhelloworld-config.cmake +++ b/projects/libhelloworld/cmake/libhelloworld-config.cmake @@ -1,8 +1,10 @@ # libhelloworld-config.cmake - package configuration file -Get_Filename_Component ( CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH ) -Include ( ${CURRENT_DIR}/libhelloworld.cmake ) - Message ( WARNING "Please configure the dependencies of this package!" ) # Include ( CMakeFindDependencyMacro ) # Find_Dependency ( ) + +Include ( FindPackageHandleStandardArgs ) +Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) +Find_Package_Handle_Standard_Args ( libhelloworld CONFIG_MODE ) +Include ( "${CMAKE_CURRENT_LIST_DIR}/libhelloworld.cmake") diff --git a/projects/libhelloworld/cmake/libhelloworld-var.cmake b/projects/libhelloworld/cmake/libhelloworld-var.cmake index ac176ec..356e349 100644 --- a/projects/libhelloworld/cmake/libhelloworld-var.cmake +++ b/projects/libhelloworld/cmake/libhelloworld-var.cmake @@ -7,6 +7,7 @@ Set ( LIBHELLOWORLD_VERSION_SHORT "${LIBHELLOWORLD Set ( LIBHELLOWORLD_VERSION "${LIBHELLOWORLD_VERSION_SHORT}.${LIBHELLOWORLD_VERSION_PATCH}.${LIBHELLOWORLD_VERSION_BUILD}" ) Set ( LIBHELLOWORLD_NAME "libhelloworld-${LIBHELLOWORLD_VERSION_SHORT}" ) Set ( LIBHELLOWORLD_OUTPUTNAME "helloworld" ) +Message ( WARNING "Please configure the output name of protject!" ) # Install directories Set ( LIBHELLOWORLD_INSTALL_DIR_INCLUDE "include/${LIBHELLOWORLD_NAME}" ) @@ -18,3 +19,14 @@ Set ( CMAKE_C_STANDARD 11 ) Set ( CMAKE_CXX_STANDARD 17 ) Set ( CMAKE_C_STANDARD_REQUIRED ON ) Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) + +# Git Version +Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) +If ( HAS_GIT_HELPER ) + GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. + LIBHELLOWORLD_VERSION_MAJOR + LIBHELLOWORLD_VERSION_MINOR + LIBHELLOWORLD_VERSION_PATCH + LIBHELLOWORLD_VERSION_BUILD + LIBHELLOWORLD_VERSION_HASH ) +EndIf ( ) diff --git a/projects/libhelloworld/src/CMakeLists.txt b/projects/libhelloworld/src/CMakeLists.txt index cd715a2..0a55ce0 100644 --- a/projects/libhelloworld/src/CMakeLists.txt +++ b/projects/libhelloworld/src/CMakeLists.txt @@ -39,11 +39,10 @@ Target_Include_Directories ( libhelloworld-objects # Static Library ################################################################################## -Message ( WARNING "Please configure the output name of the static library target!" ) Add_Library ( libhelloworld-static STATIC $ ) Set_Target_Properties ( libhelloworld-static PROPERTIES - OUTPUT_NAME "helloworld" + OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" VERSION ${LIBHELLOWORLD_VERSION} ) Target_Include_Directories ( libhelloworld-static PUBLIC @@ -52,11 +51,10 @@ Target_Include_Directories ( libhelloworld-static # Shared Library ################################################################################## -Message ( WARNING "Please configure the output name of the shared library target!" ) Add_Library ( libhelloworld-shared SHARED $ ) Set_Target_Properties ( libhelloworld-shared PROPERTIES - OUTPUT_NAME "helloworld" + OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" VERSION ${LIBHELLOWORLD_VERSION} SOVERSION ${LIBHELLOWORLD_VERSION_SHORT} ) Target_Include_Directories ( libhelloworld-shared diff --git a/projects/libhelloworld/test/CMakeLists.txt b/projects/libhelloworld/test/CMakeLists.txt index 456c640..b08ec22 100644 --- a/projects/libhelloworld/test/CMakeLists.txt +++ b/projects/libhelloworld/test/CMakeLists.txt @@ -4,10 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) -If ( HAS_PEDANTIC ) - Pedantic_Apply_Flags ( ALL ) -EndIf ( ) - # Test ############################################################################################ Find_Package ( GTest )