File tree Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Original file line number Diff line number Diff line change 1
1
.git * export-ignore
2
- / CMakeLists.txt export-subst
2
+ version.cmake export-subst
Original file line number Diff line number Diff line change @@ -228,17 +228,7 @@ elseif(NOT MSVC)
228
228
set (EXTRA_LIBRARIES ${RT} ${PTHREAD} ${DL} )
229
229
endif ()
230
230
231
- file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR} /version" )
232
- find_package (Git QUIET )
233
- if (Git_FOUND OR GIT_FOUND )
234
- message (STATUS "Found Git: ${GIT_EXECUTABLE} " )
235
- add_custom_target (version ALL "${CMAKE_COMMAND} " "-D" "GIT=${GIT_EXECUTABLE} " "-D" "TO=${CMAKE_BINARY_DIR} /version/version.h" "-P" "src/version.cmake" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} " )
236
- else ()
237
- message (STATUS "WARNING: Git was not found!" )
238
- set (VERSIONTAG "unknown" )
239
- configure_file ("src/version.h.in" "version/version.h" )
240
- add_custom_target (version ALL )
241
- endif ()
231
+ include (version .cmake )
242
232
243
233
add_subdirectory (src )
244
234
add_subdirectory (tests )
Original file line number Diff line number Diff line change
1
+ function (write_static_version_header hash )
2
+ set (VERSIONTAG "${hash} " )
3
+ configure_file ("src/version.h.in" "version/version.h" )
4
+ add_custom_target (version ALL )
5
+ endfunction ()
6
+
7
+ file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR} /version" )
8
+ find_package (Git QUIET )
9
+ if ("$Format:$" STREQUAL "" )
10
+ # We're in a tarball; use hard-coded variables.
11
+ write_static_version_header ("release" )
12
+ elseif (GIT_FOUND OR Git_FOUND )
13
+ message (STATUS "Found Git: ${GIT_EXECUTABLE} " )
14
+ add_custom_target (version ALL
15
+ COMMAND "${CMAKE_COMMAND} "
16
+ "-D" "GIT=${GIT_EXECUTABLE} "
17
+ "-D" "TO=${CMAKE_BINARY_DIR} /version/version.h"
18
+ "-P" "src/version.cmake"
19
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR} " )
20
+ else ()
21
+ message (STATUS "WARNING: Git was not found!" )
22
+ write_static_version_header ("unknown" )
23
+ endif ()
You can’t perform that action at this time.
0 commit comments