1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Fix cmake compile_definitions edge case (#13732)

If cmake variables contain just empty strings, don't add them to
the compile definitions, as this can result in incorrect version
strings in the compiled program

Signed-off-by: Mathias Gibbens <mathias@calenhad.com>

Co-authored-by: Mathias Gibbens <mathias@calenhad.com>
This commit is contained in:
Mathias Gibbens
2021-01-08 21:08:30 +00:00
committed by GitHub
parent b0a8ebc808
commit d26590c38e

View File

@@ -207,17 +207,19 @@ include_directories(${PROJECT_NAME} SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../thirdpar
# To avoid unnecessary rebuilds set the current branch and
# short sha1 only for the two files that use these
# definitions: Version.cpp and Crash/Platform.cpp
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp ${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp
PROPERTY COMPILE_DEFINITIONS
OPENRCT2_VERSION_TAG="${OPENRCT2_VERSION_TAG}")
if (NOT OPENRCT2_VERSION_TAG STREQUAL "")
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp ${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp
PROPERTY COMPILE_DEFINITIONS
OPENRCT2_VERSION_TAG="${OPENRCT2_VERSION_TAG}")
endif()
if (NOT OPENRCT2_BRANCH STREQUAL "master")
if (NOT OPENRCT2_BRANCH STREQUAL "master" AND NOT OPENRCT2_BRANCH STREQUAL "")
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp ${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp
APPEND PROPERTY COMPILE_DEFINITIONS
OPENRCT2_BRANCH="${OPENRCT2_BRANCH}")
endif()
if (NOT OPENRCT2_COMMIT_SHA1_SHORT STREQUAL "HEAD")
if (NOT OPENRCT2_COMMIT_SHA1_SHORT STREQUAL "HEAD" AND NOT OPENRCT2_COMMIT_SHA1_SHORT STREQUAL "")
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp ${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp
APPEND PROPERTY COMPILE_DEFINITIONS
OPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}")