@@ -31,6 +31,10 @@ FlibcppVersion
3131
3232#]=======================================================================]
3333
34+ if (CMAKE_SCRIPT_MODE_FILE )
35+ cmake_minimum_required (VERSION 3.8)
36+ endif ()
37+
3438function (flibcpp_find_version PROJNAME GIT_VERSION_FILE)
3539 # Get a possible Git version generated using git-archive (see the
3640 # .gitattributes file)
@@ -42,7 +46,7 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
4246 set (_CACHED_VERSION "${${_CACHE_VAR} }" )
4347 if (NOT _CACHED_VERSION)
4448 # Building from a git checkout rather than a distribution
45- find_package (Git REQUIRED)
49+ find_package (Git QUIET REQUIRED)
4650 execute_process (
4751 COMMAND "${GIT_EXECUTABLE} " "describe" "--tags" "--match" "v*"
4852 WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR} "
@@ -101,7 +105,7 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
101105 endif ()
102106
103107 if (NOT _VERSION_STRING)
104- message (WARNING "Could not determine version number ${PROJNAME} : "
108+ message (WARNING "Could not determine version number for ${PROJNAME} : "
105109 "perhaps a non-release archive?" )
106110 set (_VERSION_STRING "0.0.0" )
107111 endif ()
@@ -116,6 +120,17 @@ function(flibcpp_find_version PROJNAME GIT_VERSION_FILE)
116120 set (${PROJNAME} _VERSION_STRING "${_FULL_VERSION_STRING} " PARENT_SCOPE)
117121endfunction ()
118122
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+
119134##---------------------------------------------------------------------------##
120135## end of flibcpp/cmake/FlibcppVersion.cmake
121136##---------------------------------------------------------------------------##
0 commit comments