@@ -31,6 +31,10 @@ FlibcppVersion
31
31
32
32
#]=======================================================================]
33
33
34
+ if (CMAKE_SCRIPT_MODE_FILE )
35
+ cmake_minimum_required (VERSION 3.8)
36
+ endif ()
37
+
34
38
function (flibcpp_find_version PROJNAME GIT_VERSION_FILE)
35
39
# Get a possible Git version generated using git-archive (see the
36
40
# .gitattributes file)
@@ -42,7 +46,7 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
42
46
set (_CACHED_VERSION "${${_CACHE_VAR} }" )
43
47
if (NOT _CACHED_VERSION)
44
48
# Building from a git checkout rather than a distribution
45
- find_package (Git REQUIRED)
49
+ find_package (Git QUIET REQUIRED)
46
50
execute_process (
47
51
COMMAND "${GIT_EXECUTABLE} " "describe" "--tags" "--match" "v*"
48
52
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR} "
@@ -101,7 +105,7 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
101
105
endif ()
102
106
103
107
if (NOT _VERSION_STRING)
104
- message (WARNING "Could not determine version number ${PROJNAME} : "
108
+ message (WARNING "Could not determine version number for ${PROJNAME} : "
105
109
"perhaps a non-release archive?" )
106
110
set (_VERSION_STRING "0.0.0" )
107
111
endif ()
@@ -116,6 +120,17 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
116
120
set (${PROJNAME} _VERSION_STRING "${_FULL_VERSION_STRING} " PARENT_SCOPE)
117
121
endfunction ()
118
122
123
+ if (CMAKE_SCRIPT_MODE_FILE )
124
+ # This script is being run from the command line. Useful for debugging.
125
+ if (NOT DEFINED GIT_VERSION_FILE)
126
+ message (FATAL_ERROR "Run this script with "
127
+ "cmake -D GIT_VERSION_FILE=git-version.txt -P FlibcppVersion.cmake" )
128
+ endif ()
129
+ flibcpp_find_version(local ${GIT_VERSION_FILE} )
130
+ message (STATUS "${LOCAL_VERSION} " )
131
+ message (STATUS "${LOCAL_VERSION_STRING} " )
132
+ endif ()
133
+
119
134
##---------------------------------------------------------------------------##
120
135
## end of flibcpp/cmake/FlibcppVersion.cmake
121
136
##---------------------------------------------------------------------------##
0 commit comments