forked from aous72/OpenJPH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ojph_version.cmake
29 lines (23 loc) · 1.15 KB
/
ojph_version.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
################################################################################################
# Generating ojph library version number
################################################################################################
############################################################
# Parse version file
# credit: https://stackoverflow.com/a/47084079
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/core/common/ojph_version.h" VERFILE)
if (NOT VERFILE)
message(FATAL_ERROR "Failed to parse ojph_version.h!")
endif()
string(REGEX MATCH "OPENJPH_VERSION_MAJOR ([0-9]*)" _ ${VERFILE})
set(OPENJPH_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "OPENJPH_VERSION_MINOR ([0-9]*)" _ ${VERFILE})
set(OPENJPH_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "OPENJPH_VERSION_PATCH ([0-9]*)" _ ${VERFILE})
set(OPENJPH_VERSION_PATCH ${CMAKE_MATCH_1})
set(OPENJPH_VERSION "${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}.${OPENJPH_VERSION_PATCH}")
############################################################
message(STATUS "OpenJPH library version: ${OPENJPH_VERSION}")
if (OPENJPH_VERSION)
else()
message(FATAL_ERROR "OPENJPH_VERSION is not set")
endif()