mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-28 02:21:25 +00:00
cmake: Fix bad version strings
PROJECT_VERSION is defined by CMake, and can't be relied on.
This commit is contained in:
parent
584ee995be
commit
c1b832c03a
7 changed files with 78 additions and 70 deletions
122
CMakeLists.txt
122
CMakeLists.txt
|
@ -69,11 +69,11 @@ endif()
|
|||
################################################################################
|
||||
|
||||
# For automatic versioning, which version is the "root" of the current changes?
|
||||
set(PROJECT_VERSION_GIT_BASE "0.11.0")
|
||||
set(_VERSION_GIT_BASE "0.11.0")
|
||||
|
||||
# What is our version goal?
|
||||
set(PROJECT_VERSION "0.12.0")
|
||||
version(PARSE PROJECT_VERSION "${PROJECT_VERSION}")
|
||||
set(_VERSION "0.12.0")
|
||||
version(PARSE _VERSION "${_VERSION}")
|
||||
|
||||
# If possible, automatically generate versions from git.
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
||||
|
@ -86,10 +86,10 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
|||
if(EXISTS "${GIT}")
|
||||
# Calculate the Tweak version component from the given base version.
|
||||
execute_process(
|
||||
COMMAND "${GIT}" describe --tags --long --match "${PROJECT_VERSION_GIT_BASE}" --abbrev=8 HEAD
|
||||
COMMAND "${GIT}" describe --tags --long --match "${_VERSION_GIT_BASE}" --abbrev=8 HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
RESULT_VARIABLE GIT_RESULT
|
||||
OUTPUT_VARIABLE PROJECT_VERSION_GIT
|
||||
OUTPUT_VARIABLE _VERSION_GIT
|
||||
ERROR_VARIABLE GIT_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
|
@ -97,20 +97,20 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
|||
)
|
||||
if(GIT_RESULT EQUAL 0)
|
||||
# Some minor string editing so the output conforms to SemVer 2.0.0.
|
||||
string(REPLACE "-" ";" PROJECT_VERSION_GIT "${PROJECT_VERSION_GIT}")
|
||||
string(REPLACE "-" ";" _VERSION_GIT "${_VERSION_GIT}")
|
||||
|
||||
# Parse as SemVer 2.0.0
|
||||
list(GET PROJECT_VERSION_GIT 1 PROJECT_VERSION_GIT_TWEAK)
|
||||
list(GET PROJECT_VERSION_GIT 2 PROJECT_VERSION_GIT_BUILD)
|
||||
list(GET _VERSION_GIT 1 _VERSION_GIT_TWEAK)
|
||||
list(GET _VERSION_GIT 2 _VERSION_GIT_BUILD)
|
||||
|
||||
# Update our global version.
|
||||
version(MODIFY PROJECT_VERSION "${PROJECT_VERSION}" COMPRESS
|
||||
TWEAK "${PROJECT_VERSION_GIT_TWEAK}"
|
||||
BUILD "${PROJECT_VERSION_GIT_BUILD}"
|
||||
version(MODIFY _VERSION "${_VERSION}" COMPRESS
|
||||
TWEAK "${_VERSION_GIT_TWEAK}"
|
||||
BUILD "${_VERSION_GIT_BUILD}"
|
||||
PRERELEASE "a"
|
||||
REQUIRE "PATCH;TWEAK"
|
||||
REQUIRE PATCH TWEAK
|
||||
)
|
||||
version(PARSE PROJECT_VERSION "${PROJECT_VERSION}" REQUIRE "PATCH;TWEAK")
|
||||
version(PARSE _VERSION "${_VERSION}" REQUIRE PATCH TWEAK)
|
||||
else()
|
||||
message(WARNING "${LOGPREFIX}Unable to detect Tweak and Build component with 'git'.")
|
||||
endif()
|
||||
|
@ -120,37 +120,38 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
|||
COMMAND "${GIT}" tag "--sort=-v:refname" "--points-at" HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
RESULT_VARIABLE GIT_RESULT
|
||||
OUTPUT_VARIABLE PROJECT_VERSION_TAG
|
||||
OUTPUT_VARIABLE _VERSION_TAG
|
||||
ERROR_VARIABLE GIT_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
if((GIT_RESULT EQUAL 0) AND (NOT "${PROJECT_VERSION_TAG}" STREQUAL ""))
|
||||
if((GIT_RESULT EQUAL 0) AND (NOT "${_VERSION_TAG}" STREQUAL ""))
|
||||
# Some minor string editing so the output conforms to SemVer 2.0.0.
|
||||
string(REGEX REPLACE "[\r\n]+.*" "" PROJECT_VERSION_TAG "${PROJECT_VERSION_TAG}")
|
||||
string(REGEX REPLACE "[\r\n]+.*" "" _VERSION_TAG "${_VERSION_TAG}")
|
||||
|
||||
# Parse as SemVer 2.0.0
|
||||
version(PARSE PROJECT_VERSION_TAG "${PROJECT_VERSION_TAG}" REQUIRE "PATCH;TWEAK")
|
||||
if(PROJECT_VERSION_TAG_PRERELEASE)
|
||||
string(SUBSTRING "${PROJECT_VERSION_TAG_PRERELEASE}" 1 -1 PROJECT_VERSION_TAG_TWEAK)
|
||||
string(SUBSTRING "${PROJECT_VERSION_TAG_PRERELEASE}" 0 1 PROJECT_VERSION_TAG_PRERELEASE)
|
||||
version(PARSE _VERSION_TAG "${_VERSION_TAG}" REQUIRE PATCH TWEAK)
|
||||
if(_VERSION_TAG_PRERELEASE)
|
||||
string(SUBSTRING "${_VERSION_TAG_PRERELEASE}" 1 -1 _VERSION_TAG_TWEAK)
|
||||
string(SUBSTRING "${_VERSION_TAG_PRERELEASE}" 0 1 _VERSION_TAG_PRERELEASE)
|
||||
|
||||
if(NOT PROJECT_VERSION_TAG_TWEAK STREQUAL PROJECT_VERSION_GIT_TWEAK)
|
||||
message(WARNING "${LOGPREFIX}'git' tag mismatches detected version: '${PROJECT_VERSION_TAG_TWEAK}' != '${PROJECT_VERSION_GIT_TWEAK}'.")
|
||||
if(NOT _VERSION_TAG_TWEAK STREQUAL _VERSION_GIT_TWEAK)
|
||||
message(WARNING "${LOGPREFIX}'git' tag mismatches detected version: '${_VERSION_TAG_TWEAK}' != '${_VERSION_GIT_TWEAK}'.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Update our global version.
|
||||
version(GENERATE PROJECT_VERSION COMPRESS
|
||||
MAJOR "${PROJECT_VERSION_TAG_MAJOR}"
|
||||
MINOR "${PROJECT_VERSION_TAG_MINOR}"
|
||||
PATCH "${PROJECT_VERSION_TAG_PATCH}"
|
||||
TWEAK "${PROJECT_VERSION_TAG_TWEAK}"
|
||||
PRERELEASE "${PROJECT_VERSION_TAG_PRERELEASE}"
|
||||
BUILD "${PROJECT_VERSION_BUILD}"
|
||||
version(GENERATE _VERSION COMPRESS
|
||||
MAJOR "${_VERSION_TAG_MAJOR}"
|
||||
MINOR "${_VERSION_TAG_MINOR}"
|
||||
PATCH "${_VERSION_TAG_PATCH}"
|
||||
TWEAK "${_VERSION_TAG_TWEAK}"
|
||||
PRERELEASE "${_VERSION_TAG_PRERELEASE}"
|
||||
BUILD "${_VERSION_BUILD}"
|
||||
REQUIRE PATCH TWEAK
|
||||
)
|
||||
version(PARSE PROJECT_VERSION "${PROJECT_VERSION}" REQUIRE "PATCH;TWEAK")
|
||||
version(PARSE _VERSION "${_VERSION}" REQUIRE PATCH TWEAK)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "${LOGPREFIX}'git' not found, automatic version detection disabled.")
|
||||
|
@ -162,37 +163,46 @@ endif()
|
|||
# Allow manual overrides of the detected version.
|
||||
set(${PREFIX}VERSION "" CACHE STRING "Override detected or pre-configured version with this string. Accepts strings in CMake and SemVer 2.0.0 format.")
|
||||
if(NOT ("${${PREFIX}VERSION}" STREQUAL ""))
|
||||
version(PARSE PROJECT_VERSION_CFG "${${PREFIX}VERSION}" REQUIRE "PATCH;TWEAK")
|
||||
if("${PROJECT_VERSION_CFG_BUILD}" STREQUAL "")
|
||||
set(PROJECT_VERSION_CFG_BUILD "${PROJECT_VERSION_BUILD}")
|
||||
version(PARSE _VERSION_CFG "${${PREFIX}VERSION}" REQUIRE PATCH TWEAK)
|
||||
if("${_VERSION_CFG_BUILD}" STREQUAL "")
|
||||
set(_VERSION_CFG_BUILD "${_VERSION_BUILD}")
|
||||
endif()
|
||||
version(GENERATE PROJECT_VERSION COMPRESS
|
||||
MAJOR "${PROJECT_VERSION_CFG_MAJOR}"
|
||||
MINOR "${PROJECT_VERSION_CFG_MINOR}"
|
||||
PATCH "${PROJECT_VERSION_CFG_PATCH}"
|
||||
TWEAK "${PROJECT_VERSION_CFG_TWEAK}"
|
||||
PRERELEASE "${PROJECT_VERSION_CFG_PRERELEASE}"
|
||||
BUILD "${PROJECT_VERSION_CFG_BUILD}"
|
||||
version(GENERATE _VERSION COMPRESS
|
||||
MAJOR "${_VERSION_CFG_MAJOR}"
|
||||
MINOR "${_VERSION_CFG_MINOR}"
|
||||
PATCH "${_VERSION_CFG_PATCH}"
|
||||
TWEAK "${_VERSION_CFG_TWEAK}"
|
||||
PRERELEASE "${_VERSION_CFG_PRERELEASE}"
|
||||
BUILD "${_VERSION_CFG_BUILD}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(_VERSION_THIN "${_VERSION_MAJOR}.${_VERSION_MINOR}.${_VERSION_PATCH}")
|
||||
if(NOT (_VERSION_PRERELEASE STREQUAL ""))
|
||||
set(_VERSION_THIN "${_VERSION_THIN}${_VERSION_PRERELEASE}${_VERSION_TWEAK}")
|
||||
endif()
|
||||
if(NOT (VERSION_COMMIT STREQUAL ""))
|
||||
set(_VERSION_THIN "${_VERSION_THIN}-${_VERSION_BUILD}")
|
||||
endif()
|
||||
|
||||
# Parse & Log the detected version.
|
||||
message(STATUS "${LOGPREFIX}Version ${PROJECT_VERSION}")
|
||||
message(STATUS "${LOGPREFIX}Version ${_VERSION}")
|
||||
|
||||
################################################################################
|
||||
# Project
|
||||
################################################################################
|
||||
|
||||
# Metadata
|
||||
version(GENERATE PROJECT_VERSION_CMAKE
|
||||
MAJOR "${PROJECT_VERSION_MAJOR}"
|
||||
MINOR "${PROJECT_VERSION_MINOR}"
|
||||
PATCH "${PROJECT_VERSION_PATCH}"
|
||||
TWEAK "${PROJECT_VERSION_TWEAK}"
|
||||
version(GENERATE PROJECT_VERSION
|
||||
MAJOR "${_VERSION_MAJOR}"
|
||||
MINOR "${_VERSION_MINOR}"
|
||||
PATCH "${_VERSION_PATCH}"
|
||||
TWEAK "${_VERSION_TWEAK}"
|
||||
REQUIRE PATCH TWEAK
|
||||
)
|
||||
project(
|
||||
StreamFX
|
||||
VERSION ${PROJECT_VERSION_CMAKE}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
DESCRIPTION "Additional sources, filters, transitions and encoders for OBS Studio."
|
||||
HOMEPAGE_URL "https://streamfx.xaymar.com/"
|
||||
)
|
||||
|
@ -1887,15 +1897,13 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
|||
IMPORT_PREFIX ""
|
||||
)
|
||||
|
||||
# Set file version (on anything but MacOS)
|
||||
if(NOT D_PLATFORM_MAC)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACHO_COMPATIBILITY_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACHO_CURRENT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}
|
||||
)
|
||||
endif()
|
||||
# Set file version
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACHO_COMPATIBILITY_VERSION ${_VERSION_MAJOR}.${_VERSION_MINOR}
|
||||
MACHO_CURRENT_VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${_VERSION_MAJOR}.${_VERSION_MINOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
|
||||
# Delay-Loading on Microsoft Visual C++
|
||||
if(D_PLATFORM_WINDOWS)
|
||||
|
@ -2194,7 +2202,7 @@ endif()
|
|||
if(STANDALONE)
|
||||
# Packaging
|
||||
if(NOT PACKAGE_SUFFIX)
|
||||
set(_PACKAGE_SUFFIX_OVERRIDE "${PROJECT_VERSION}")
|
||||
set(_PACKAGE_SUFFIX_OVERRIDE "${_VERSION_THIN}")
|
||||
else()
|
||||
set(_PACKAGE_SUFFIX_OVERRIDE "${PACKAGE_SUFFIX}")
|
||||
endif()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2494a2b6c894380ced96307ae833afc0be37a143
|
||||
Subproject commit 16bfa9568c3d72e07d94c214a0da53956c7a33eb
|
|
@ -2,8 +2,8 @@
|
|||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "@PROJECT_TITLE@"
|
||||
#define MyAppVersion "@PROJECT_VERSION_CMAKE@"
|
||||
#define MyAppVersionText "@PROJECT_VERSION@"
|
||||
#define MyAppVersion "@PROJECT_VERSION@"
|
||||
#define MyAppVersionText "@_VERSION@"
|
||||
#define MyAppPublisher "Xaymars Technology Workshop"
|
||||
#define MyAppURL "https://xaymar.com/"
|
||||
#define MyAppCopyright "@PROJECT_COPYRIGHT@"
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "@PROJECT_TITLE@"
|
||||
#define MyAppVersion "@PROJECT_VERSION_CMAKE@"
|
||||
#define MyAppVersionText "@PROJECT_VERSION@"
|
||||
#define MyAppVersion "@PROJECT_VERSION@"
|
||||
#define MyAppVersionText "@_VERSION@"
|
||||
#define MyAppPublisher "Xaymars Technology Workshop"
|
||||
#define MyAppURL "https://xaymar.com/"
|
||||
#define MyAppCopyright "@PROJECT_COPYRIGHT@"
|
||||
|
|
|
@ -528,7 +528,7 @@
|
|||
<key>USE_HFS+_COMPRESSION</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<string>@PROJECT_VERSION_CMAKE@</string>
|
||||
<string>@PROJECT_VERSION@</string>
|
||||
</dict>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
#define STREAMFX_VERSION_MINOR @PROJECT_VERSION_MINOR@u
|
||||
#define STREAMFX_VERSION_PATCH @PROJECT_VERSION_PATCH@u
|
||||
#define STREAMFX_VERSION_TWEAK @PROJECT_VERSION_TWEAK@u
|
||||
#define STREAMFX_VERSION_PRERELEASE "@PROJECT_VERSION_PRERELEASE@"
|
||||
#define STREAMFX_VERSION_BUILD "@PROJECT_VERSION_BUILD@"
|
||||
#define STREAMFX_VERSION_PRERELEASE "@_VERSION_PRERELEASE@"
|
||||
#define STREAMFX_VERSION_BUILD "@_VERSION_BUILD@"
|
||||
#define STREAMFX_VERSION \
|
||||
STREAMFX_MAKE_VERSION(STREAMFX_VERSION_MAJOR, STREAMFX_VERSION_MINOR, STREAMFX_VERSION_PATCH, \
|
||||
STREAMFX_VERSION_TWEAK)
|
||||
#define STREAMFX_VERSION_STRING "@PROJECT_VERSION@"
|
||||
#define STREAMFX_VERSION_STRING "@_VERSION_THIN@"
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @PROJECT_VERSION_CMAKE@
|
||||
PRODUCTVERSION @PROJECT_VERSION_CMAKE@
|
||||
FILEVERSION @PROJECT_VERSION@
|
||||
PRODUCTVERSION @PROJECT_VERSION@
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS (VER_DEBUG)
|
||||
FILEOS VOS__WINDOWS32
|
||||
|
@ -29,8 +29,8 @@ BEGIN
|
|||
VALUE "CompanyName", "@PROJECT_AUTHORS@\0"
|
||||
VALUE "LegalCopyright", "@PROJECT_COPYRIGHT@\0"
|
||||
VALUE "LegalTrademarks", "@PROJECT_TRADEMARKS@\0"
|
||||
VALUE "FileVersion", "@VERSION_STRING@\0"
|
||||
VALUE "ProductVersion", "@VERSION_STRING@\0"
|
||||
VALUE "FileVersion", "@_VERSION@\0"
|
||||
VALUE "ProductVersion", "@_VERSION@\0"
|
||||
END
|
||||
END
|
||||
|
||||
|
|
Loading…
Reference in a new issue