Sanitized the 'sane CMake' patch to not include the version components

This commit is contained in:
István Váradi 2020-12-14 17:23:21 +01:00
parent 2020f49a30
commit cd81950cb9

View File

@ -13,62 +13,6 @@ Last-Update: 2019-11-17
# need this logic to not mess with re/uninstallations via macosx.pkgproj
if(${APPLICATION_REV_DOMAIN} STREQUAL "com.owncloud.desktopclient")
set(APPLICATION_REV_DOMAIN_INSTALLER "com.ownCloud.client")
@@ -39,7 +40,54 @@ endif()
include(Warnings)
-include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
+# We don't want VERSION.cmake anymore
+# include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
+set( MIRALL_VERSION_MAJOR 3 )
+set( MIRALL_VERSION_MINOR 1 )
+set( MIRALL_VERSION_PATCH 50 )
+set( MIRALL_VERSION_YEAR 2020 )
+set( MIRALL_SOVERSION 0 )
+
+# Composite defines
+# Used e.g. for libraries Keep at x.y.z.
+set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" )
+
+if( NOT DEFINED MIRALL_VERSION_BUILD )
+ set( MIRALL_VERSION_BUILD "0" ) # Integer ID. Generated by the build system
+endif( NOT DEFINED MIRALL_VERSION_BUILD )
+
+# Version with Build ID. Used in the installer
+set( MIRALL_VERSION_FULL "${MIRALL_VERSION}.${MIRALL_VERSION_BUILD}" )
+
+# External version or version with suffix
+if ( NOT DEFINED EXTERNAL_VERSION )
+ if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
+ set ( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
+ endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
+ include(GetGitRevisionDescription)
+ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
+ # if we cannot get it from git, directly try .tag (packages)
+ # this will work if the tar balls have been properly created
+ # via git-archive.
+ if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
+ file (READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
+ string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
+ if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
+ message("sha1_candidate:${sha1_candidate}")
+ set (GIT_SHA1 "${sha1_candidate}")
+ endif (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
+ endif ( "${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND" )
+ message(STATUS "GIT_SHA1 ${GIT_SHA1}")
+ set ( MIRALL_VERSION_STRING "${MIRALL_VERSION}${MIRALL_VERSION_SUFFIX}" )
+else ( NOT DEFINED EXTERNAL_VERSION )
+ set ( MIRALL_VERSION_STRING "${EXTERNAL_VERSION}" )
+endif ( NOT DEFINED EXTERNAL_VERSION )
+
+if( MIRALL_VERSION_BUILD )
+ set( MIRALL_VERSION_STRING "${MIRALL_VERSION_STRING} (build ${MIRALL_VERSION_BUILD})" )
+endif( MIRALL_VERSION_BUILD )
+# end of the included file
+
# For config.h
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
# Allows includes based on src/ like #include "common/utility.h" or #include "csync/csync.h"
@@ -61,29 +109,12 @@ include(GNUInstallDirs)
include(DefineInstallationPaths)
include(GenerateExportHeader)
@ -239,31 +183,53 @@ Last-Update: 2019-11-17
-set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackOptions.cmake") # File included at cpack time, once per generator after setting CPACK_GENERATOR to the actual generator being used; allows per-generator setting of CPACK_* variables at cpack time. ${PROJECT_BINARY_DIR}/CPackOptions.cmake
-include(CPack)
--- a/VERSION.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-set( MIRALL_VERSION_MAJOR 3 )
-set( MIRALL_VERSION_MINOR 1 )
-set( MIRALL_VERSION_PATCH 50 )
-set( MIRALL_VERSION_YEAR 2020 )
-set( MIRALL_SOVERSION 0 )
-
+++ b/VERSION.cmake
@@ -4,20 +4,38 @@ set( MIRALL_VERSION_PATCH 50 )
-if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
- set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
-endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
-
-if( NOT DEFINED MIRALL_VERSION_BUILD )
- set( MIRALL_VERSION_BUILD "0" ) # Integer ID. Generated by the build system
-endif( NOT DEFINED MIRALL_VERSION_BUILD )
+# Composite defines
+# Used e.g. for libraries Keep at x.y.z.
+set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" )
if( NOT DEFINED MIRALL_VERSION_BUILD )
set( MIRALL_VERSION_BUILD "0" ) # Integer ID. Generated by the build system
endif( NOT DEFINED MIRALL_VERSION_BUILD )
-# Composite defines
-# Used e.g. for libraries Keep at x.y.z.
-set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" )
-# Version with Build ID. Used in the installer
+
# Version with Build ID. Used in the installer
-set( MIRALL_VERSION_FULL ${MIRALL_VERSION} )
-set( MIRALL_VERSION_STRING ${MIRALL_VERSION} )
-set( MIRALL_VERSION_FULL "${MIRALL_VERSION_FULL}.${MIRALL_VERSION_BUILD}" )
-
+set( MIRALL_VERSION_FULL "${MIRALL_VERSION}.${MIRALL_VERSION_BUILD}" )
-set( MIRALL_VERSION_STRING "${MIRALL_VERSION}${MIRALL_VERSION_SUFFIX}" )
-
-if( MIRALL_VERSION_BUILD )
- set( MIRALL_VERSION_STRING "${MIRALL_VERSION_STRING} (build ${MIRALL_VERSION_BUILD})" )
-endif( MIRALL_VERSION_BUILD )
+# External version or version with suffix
+if ( NOT DEFINED EXTERNAL_VERSION )
+ if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
+ set ( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
+ endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
+ include(GetGitRevisionDescription)
+ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
+ # if we cannot get it from git, directly try .tag (packages)
+ # this will work if the tar balls have been properly created
+ # via git-archive.
+ if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
+ file (READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
+ string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
+ if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
+ message("sha1_candidate:${sha1_candidate}")
+ set (GIT_SHA1 "${sha1_candidate}")
+ endif (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
+ endif ( "${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND" )
+ message(STATUS "GIT_SHA1 ${GIT_SHA1}")
+ set ( MIRALL_VERSION_STRING "${MIRALL_VERSION}${MIRALL_VERSION_SUFFIX}" )
+else ( NOT DEFINED EXTERNAL_VERSION )
+ set ( MIRALL_VERSION_STRING "${EXTERNAL_VERSION}" )
+endif ( NOT DEFINED EXTERNAL_VERSION )
if( MIRALL_VERSION_BUILD )
set( MIRALL_VERSION_STRING "${MIRALL_VERSION_STRING} (build ${MIRALL_VERSION_BUILD})" )