Skip to content

Commit aaf0b5f

Browse files
giladreichSiegeLord
authored andcommitted
Make cmake parse version from base.h file.
+ Update README_releasing.txt to use fixver.sh script.
1 parent c2c258e commit aaf0b5f

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

CMakeLists.txt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,31 @@ if(COMMAND cmake_policy)
2222
endif()
2323
endif(COMMAND cmake_policy)
2424

25-
#-----------------------------------------------------------------------------#
26-
#
27-
# Build system setup
28-
#
29-
#-----------------------------------------------------------------------------#
3025

31-
# Set the project name.
32-
# We use C++ in a few cases.
33-
set(ALLEGRO_PROJECT_SUFFIX "" CACHE STRING "Project suffix")
34-
set(ALLEGRO_PROJECT_NAME "ALLEGRO" CACHE STRING "Project default name")
26+
##################################################################################################################
27+
# VERSION
28+
##################################################################################################################
29+
30+
set(ALLEGRO_VERSION_REGEX_PATTERN "#define ALLEGRO_VERSION_STR[ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+).*\"")
31+
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/include/allegro5/base.h" ALLEGRO_VERSION_MATCH
32+
REGEX ${ALLEGRO_VERSION_REGEX_PATTERN}
33+
LIMIT_COUNT 1
34+
)
35+
string(REGEX REPLACE ${ALLEGRO_VERSION_REGEX_PATTERN} "\\1" ALLEGRO_VERSION "${ALLEGRO_VERSION_MATCH}")
36+
if("${ALLEGRO_VERSION}" VERSION_GREATER_EQUAL 5.0.0)
37+
message(STATUS "[Allegro] Allegro Version: [${ALLEGRO_VERSION}]")
38+
else()
39+
message(FATAL_ERROR "[Allegro] Invalid Allegro Version: [${ALLEGRO_VERSION}]")
40+
endif()
41+
3542

36-
set(ALLEGRO_VERSION 5.2.9)
43+
##################################################################################################################
44+
# PROJECT
45+
##################################################################################################################
46+
47+
# Allow generating custom project name via command-line arguments (#1174)
48+
set(ALLEGRO_PROJECT_NAME "ALLEGRO" CACHE STRING "Project default name")
49+
set(ALLEGRO_PROJECT_SUFFIX "" CACHE STRING "Project suffix")
3750

3851
project(${ALLEGRO_PROJECT_NAME}${ALLEGRO_PROJECT_SUFFIX}
3952
VERSION ${ALLEGRO_VERSION}

README_releasing.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ on Linux.
1818
git cherry-pick -x badf00d
1919

2020
2. On the master branch, bump the version to the next release and update the
21-
dates. This is done in `include/allegro5/base.h`. Also, change
22-
ALLEGRO_VERSION in `CMakeLists.txt`. Commit this change.
21+
dates by using the `misc/fixver.sh` script. Commit this change.
2322

2423
3. Write a changelog file. This is located in docs/src/changes-5.2.txt.
2524

0 commit comments

Comments
 (0)