Improved git versioning

This commit is contained in:
wheremyfoodat 2024-08-20 13:20:14 +03:00
parent dfc7b59de2
commit c694ce9a25
6 changed files with 32 additions and 6 deletions

View file

@ -18,7 +18,6 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
project(Alber)
set(PANDA3DS_VERSION "0.8")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(APPLE)
@ -44,6 +43,7 @@ option(ENABLE_HTTP_SERVER "Enable HTTP server. Used for Discord bot support" OFF
option(ENABLE_DISCORD_RPC "Compile with Discord RPC support (disabled by default)" ON)
option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON)
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON)
option(BUILD_HYDRA_CORE "Build a Hydra core" OFF)
option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF)
@ -61,8 +61,15 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND ENABLE_USER_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-")
endif()
# Generate versioning files
find_package(Git)
if(GIT_FOUND)
set(PANDA3DS_VERSION "0.8")
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/version.hpp.in)
file(WRITE ${CMAKE_BINARY_DIR}/include/version.hpp.in "#define PANDA3DS_VERSION \"\${PANDA3DS_VERSION}\"")
endif()
if(GIT_FOUND AND ENABLE_GIT_VERSIONING)
execute_process(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
OUTPUT_VARIABLE PANDA3DS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
@ -82,7 +89,7 @@ if(GIT_FOUND)
string(REGEX REPLACE "^v" "" PANDA3DS_VERSION "${PANDA3DS_VERSION}")
unset(git_version_tag)
endif()
configure_file(${PROJECT_SOURCE_DIR}/include/version.hpp.in ${CMAKE_BINARY_DIR}/include/version.hpp)
configure_file(${CMAKE_BINARY_DIR}/include/version.hpp.in ${CMAKE_BINARY_DIR}/include/version.hpp)
include_directories(${CMAKE_BINARY_DIR}/include/)
add_library(AlberCore STATIC)