mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Fixed version extraction in CMake
This commit is contained in:
parent
c56ee8ec03
commit
8d3d06b7a0
@ -2,16 +2,23 @@
|
|||||||
function(spdlog_extract_version)
|
function(spdlog_extract_version)
|
||||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
|
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
|
||||||
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
set(ver_major ${CMAKE_MATCH_1})
|
set(ver_major ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(ver_minor ${CMAKE_MATCH_1})
|
set(ver_minor ${CMAKE_MATCH_1})
|
||||||
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
|
||||||
|
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
|
||||||
|
endif()
|
||||||
set(ver_patch ${CMAKE_MATCH_1})
|
set(ver_patch ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
if (NOT ver_major OR NOT ver_minor OR NOT ver_patch)
|
|
||||||
message(FATAL_ERROR "Could not extract valid version from spdlog/version.h")
|
|
||||||
endif()
|
|
||||||
set (SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE)
|
set (SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -7,4 +7,5 @@
|
|||||||
#define SPDLOG_VER_MINOR 4
|
#define SPDLOG_VER_MINOR 4
|
||||||
#define SPDLOG_VER_PATCH 0
|
#define SPDLOG_VER_PATCH 0
|
||||||
|
|
||||||
|
|
||||||
#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)
|
#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)
|
||||||
|
Loading…
Reference in New Issue
Block a user