mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-23 10:53:27 +08:00
cmake: Retrieve the git revision on platforms without bash
This commit is contained in:
parent
6301cfda95
commit
67aacfe5c0
@ -2378,11 +2378,34 @@ listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
|
||||
set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
|
||||
|
||||
# Compat helpers for the configuration files
|
||||
if(NOT CMAKE_HOST_WIN32)
|
||||
# TODO: we need a Windows script, too
|
||||
execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh
|
||||
WORKING_DIRECTORY ${SDL2_BINARY_DIR})
|
||||
find_package(Git)
|
||||
if(Git_FOUND)
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}" remote get-url origin
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE GIT_URL_STATUS
|
||||
OUTPUT_VARIABLE GIT_URL
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}" rev-list --max-count=1 HEAD~..
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE GIT_REVISION_STATUS
|
||||
OUTPUT_VARIABLE GIT_REVISION
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(GIT_URL_STATUS EQUAL 0 OR GIT_REVISION_STATUS EQUAL 0)
|
||||
set(SDL_REVISION "${GIT_URL}@${GIT_REVISION}")
|
||||
else()
|
||||
set(SDL_REVISION "")
|
||||
endif()
|
||||
else()
|
||||
set(SDL_REVISION "")
|
||||
endif()
|
||||
|
||||
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
|
||||
"${SDL2_BINARY_DIR}/include/SDL_revision.h")
|
||||
|
||||
if(NOT WINDOWS OR CYGWIN OR MINGW)
|
||||
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
@ -2513,6 +2536,7 @@ message(STATUS "")
|
||||
message(STATUS "Platform: ${CMAKE_SYSTEM}")
|
||||
message(STATUS "64-bit: ${ARCH_64}")
|
||||
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
|
||||
message(STATUS "Revision: ${SDL_REVISION}")
|
||||
message(STATUS "")
|
||||
message(STATUS "Subsystems:")
|
||||
foreach(_SUB ${SDL_SUBSYSTEMS})
|
||||
|
6
include/SDL_revision.h.cmake
Normal file
6
include/SDL_revision.h.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
#cmakedefine SDL_REVISION "@SDL_REVISION@"
|
||||
#define SDL_REVISION_NUMBER 0
|
||||
|
||||
#ifndef SDL_REVISION
|
||||
#define SDL_REVISION ""
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user