Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit e2df358

Browse files
committed
cmake: Simplify version handling and setting, add patch version
1 parent 126db27 commit e2df358

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

CMakeLists.txt

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,13 @@
1515

1616
cmake_minimum_required (VERSION 2.6)
1717
project (jem)
18+
set(VERSION_MAJOR 0)
19+
set(VERSION_MINOR 2)
20+
set(VERSION_PATCH 0)
21+
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
1822

19-
file(STRINGS "${PROJECT_SOURCE_DIR}/include/version.h"
20-
JEM_BUILD_SPEC REGEX "^[ \t]*#define[ \t]+JEM_VERSION_[A-Z]+[ \t]+[0-9]+.*$")
21-
22-
if(JEM_BUILD_SPEC)
23-
message(STATUS "${JEM_BUILD_SPEC}")
24-
foreach(item IN ITEMS MAJOR MINOR PATCH)
25-
string(REGEX REPLACE ".*#define[ \t]+JEM_VERSION_${item}[ \t]+([0-9]+).*"
26-
"\\1" XYZ ${JEM_BUILD_SPEC})
27-
set("JEM_VERSION_${item}" ${XYZ} CACHE STRING "Jem version")
28-
endforeach()
29-
else()
30-
message(FATAL_ERROR "Version unavilable")
31-
endif()
32-
33-
set(VERSION "${JEM_VERSION_MAJOR}.${JEM_VERSION_MINOR}")
23+
configure_file ("${PROJECT_SOURCE_DIR}/include/version.h.in"
24+
"${PROJECT_SOURCE_DIR}/include/version.h" )
3425

3526
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g")
3627
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
@@ -48,8 +39,8 @@ add_library(jem SHARED src/output_formatter.c src/file_parser.c src/vm.c src/pac
4839
add_executable(jem-cli src/main.c)
4940
add_executable(jem-test EXCLUDE_FROM_ALL tests/test.c)
5041
set_target_properties(jem PROPERTIES
51-
SOVERSION ${JEM_VERSION_MAJOR}
52-
VERSION ${JEM_VERSION_MAJOR}.${JEM_VERSION_MINOR})
42+
SOVERSION ${VERSION_MAJOR}
43+
VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
5344
set_target_properties(jem-cli PROPERTIES OUTPUT_NAME jem)
5445
target_link_libraries(jem-cli jem)
5546
target_link_libraries(jem-test jem)
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
* along with jem. If not, see <http://www.gnu.org/licenses/>.
2222
*/
2323

24-
#define STR_HELPER(x) #x
25-
#define STR(x) STR_HELPER(x)
26-
2724
#define JEM_CONTACT "Obsidian-Studios, Inc. <jem@o-sinc.com>"
28-
#define JEM_VERSION_MAJOR 0
29-
#define JEM_VERSION_MINOR 2
30-
#define JEM_VERSION_SEPARATOR "."
31-
#define JEM_VERSION_NUMERIC STR(JEM_VERSION_MAJOR) "." STR(JEM_VERSION_MINOR)
32-
#define JEM_VERSION_STR "jem, v" JEM_VERSION_NUMERIC
25+
#define JEM_VERSION_MAJOR @VERSION_MAJOR@
26+
#define JEM_VERSION_MINOR @VERSION_MINOR@
27+
#define JEM_VERSION_PATCH @VERSION_PATCH@
28+
#define JEM_VERSION_STR "jem, v@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"

0 commit comments

Comments
 (0)