diff --git a/CMakeModules/DuckStationUtils.cmake b/CMakeModules/DuckStationUtils.cmake index cdc01a52c..066d3d832 100644 --- a/CMakeModules/DuckStationUtils.cmake +++ b/CMakeModules/DuckStationUtils.cmake @@ -200,3 +200,24 @@ int main() { set(HOST_CACHE_LINE_SIZE ${detect_cache_line_size_output} CACHE STRING "Reported host cache line size") endif() endfunction() + +function(get_scm_version) + if(SCM_VERSION) + return() + endif() + + find_package(Git) + if(EXISTS "${PROJECT_SOURCE_DIR}/.git" AND GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --dirty + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + OUTPUT_VARIABLE LOCAL_SCM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() + if(NOT LOCAL_SCM_VERSION) + set(SCM_VERSION "unknown" PARENT_SCOPE) + else() + set(SCM_VERSION ${LOCAL_SCM_VERSION} PARENT_SCOPE) + endif() +endfunction() diff --git a/src/duckstation-qt/CMakeLists.txt b/src/duckstation-qt/CMakeLists.txt index 002f3e3fd..2e3ae8724 100644 --- a/src/duckstation-qt/CMakeLists.txt +++ b/src/duckstation-qt/CMakeLists.txt @@ -225,8 +225,9 @@ if(WIN32) elseif(APPLE) # Don't generate a bundle for XCode, it makes code signing fail... if(NOT CMAKE_GENERATOR MATCHES "Xcode") + get_scm_version() set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DuckStation.app) - set_target_properties(duckstation-qt PROPERTIES + set_target_properties(duckstation-qt PROPERTIES MACOSX_BUNDLE true MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in OUTPUT_NAME DuckStation diff --git a/src/duckstation-qt/Info.plist.in b/src/duckstation-qt/Info.plist.in index 306a0c058..dc21c588d 100644 --- a/src/duckstation-qt/Info.plist.in +++ b/src/duckstation-qt/Info.plist.in @@ -33,8 +33,12 @@ English CFBundlePackageType APPL + CFBundleShortVersionString + ${SCM_VERSION} + CFBundleVersionString + ${SCM_VERSION} NSHumanReadableCopyright - 2019-2023 Connor McLaughlin <stenzek@gmail.com> + 2019-2024 Connor McLaughlin <stenzek@gmail.com> LSMinimumSystemVersion ${CMAKE_OSX_DEPLOYMENT_TARGET} LSApplicationCategoryType