Skip to content

Commit

Permalink
Fix: [CMake] Auto-fill version details in rev.cpp and ottres.rc (Open…
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Apr 20, 2021
1 parent fe3cd18 commit d4f0b6f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Expand Up @@ -4,7 +4,9 @@ if(NOT BINARY_NAME)
set(BINARY_NAME openttd)
endif()

project(${BINARY_NAME})
project(${BINARY_NAME}
VERSION 1.12.0
)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the build directory. You may need to delete \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" first.")
Expand Down Expand Up @@ -72,6 +74,9 @@ add_custom_target(find_version
${CMAKE_COMMAND}
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
-DREV_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}
-DREV_MINOR=${CMAKE_PROJECT_VERSION_MINOR}
-DREV_BUILD=${CMAKE_PROJECT_VERSION_PATCH}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
BYPRODUCTS ${GENERATED_SOURCE_FILES}
Expand Down
10 changes: 10 additions & 0 deletions cmake/scripts/FindVersion.cmake
@@ -1,5 +1,15 @@
cmake_minimum_required(VERSION 3.5)

if(NOT REV_MAJOR)
set(REV_MAJOR 0)
endif()
if(NOT REV_MINOR)
set(REV_MINOR 0)
endif()
if(NOT REV_BUILD)
set(REV_BUILD 0)
endif()

#
# Finds the current version of the current folder.
#
Expand Down
4 changes: 2 additions & 2 deletions src/os/windows/ottdres.rc.in
Expand Up @@ -77,8 +77,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,11,0,${REV_ISODATE}
PRODUCTVERSION 1,11,0,${REV_ISODATE}
FILEVERSION ${REV_MAJOR},${REV_MINOR},${REV_BUILD},${REV_ISODATE}
PRODUCTVERSION ${REV_MAJOR},${REV_MINOR},${REV_BUILD},${REV_ISODATE}
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand Down
2 changes: 1 addition & 1 deletion src/rev.cpp.in
Expand Up @@ -85,4 +85,4 @@ const byte _openttd_revision_tagged = ${REV_ISTAG};
* final release will always have a lower version number than the released
* version, thus making comparisons on specific revisions easy.
*/
const uint32 _openttd_newgrf_version = 1 << 28 | 12 << 24 | 0 << 20 | ${REV_ISSTABLETAG} << 19 | 28004;
const uint32 _openttd_newgrf_version = ${REV_MAJOR} << 28 | ${REV_MINOR} << 24 | ${REV_BUILD} << 20 | ${REV_ISSTABLETAG} << 19 | 28004;

0 comments on commit d4f0b6f

Please sign in to comment.