diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b6a82ad..1213ab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,13 +13,25 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC) endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC) # Version -set (project_VERSION_MAJOR "0") -set (project_VERSION_MINOR "9") -set (project_VERSION_PATCH "2") - -set (project_VERSION "${project_VERSION_MAJOR}") -set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}") -set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}") +set (project_version "0.9.2") + +# Try to append commit ID if it follows a version tag. It might be nicer if +# we could also detect dirty worktrees but that's very hard to get right. +find_package (Git) +set (git_head "${PROJECT_SOURCE_DIR}/.git/HEAD") +if (GIT_FOUND AND EXISTS ${git_head}) + configure_file (${git_head} git-head.tag COPYONLY) + execute_process (COMMAND ${GIT_EXECUTABLE} describe --tags --match v* + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE git_describe_result + OUTPUT_VARIABLE git_describe OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT git_describe_result) + string (REGEX REPLACE "^v" "" project_version "${git_describe}") + endif (NOT git_describe_result) +endif (GIT_FOUND AND EXISTS ${git_head}) + +# Dashes make filenames confusing and upset packaging software +string (REPLACE "-" "+" project_version_safe "${project_version}") # Dependencies set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake) @@ -197,19 +209,19 @@ endforeach (page) # CPack set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Experimental IRC client, daemon and bot") -set (CPACK_PACKAGE_VERSION ${project_VERSION}) +set (CPACK_PACKAGE_VERSION "${project_version_safe}") set (CPACK_PACKAGE_VENDOR "Premysl Janouch") set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>") set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set (CPACK_GENERATOR "TGZ;ZIP") set (CPACK_PACKAGE_FILE_NAME - "${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") -set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}") + "${PROJECT_NAME}-${project_version_safe}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_version_safe}") set (CPACK_SOURCE_GENERATOR "TGZ;ZIP") set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user") -set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}") +set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_version_safe}") set (CPACK_SET_DESTDIR TRUE) include (CPack) |