CMake: Fill version in bundle info plist

This commit is contained in:
Stenzek 2024-08-05 00:29:12 +10:00
parent 6e795c8977
commit d862043f1d
No known key found for this signature in database
3 changed files with 28 additions and 2 deletions

View File

@ -200,3 +200,24 @@ int main() {
set(HOST_CACHE_LINE_SIZE ${detect_cache_line_size_output} CACHE STRING "Reported host cache line size") set(HOST_CACHE_LINE_SIZE ${detect_cache_line_size_output} CACHE STRING "Reported host cache line size")
endif() endif()
endfunction() 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()

View File

@ -225,8 +225,9 @@ if(WIN32)
elseif(APPLE) elseif(APPLE)
# Don't generate a bundle for XCode, it makes code signing fail... # Don't generate a bundle for XCode, it makes code signing fail...
if(NOT CMAKE_GENERATOR MATCHES "Xcode") if(NOT CMAKE_GENERATOR MATCHES "Xcode")
get_scm_version()
set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DuckStation.app) 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 true
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
OUTPUT_NAME DuckStation OUTPUT_NAME DuckStation

View File

@ -33,8 +33,12 @@
<string>English</string> <string>English</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${SCM_VERSION}</string>
<key>CFBundleVersionString</key>
<string>${SCM_VERSION}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>2019-2023 Connor McLaughlin &lt;stenzek@gmail.com&gt;</string> <string>2019-2024 Connor McLaughlin &lt;stenzek@gmail.com&gt;</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string> <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>