Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
cmake_minimum_required(VERSION 3.23)

# Read the version from the public header so it stays the single source of truth.
function(_zeus_expected_parse_header_version header result_var)
file(READ "${header}" _header)
foreach(_comp MAJOR MINOR PATCH)
string(REGEX MATCH "#define ZEUS_EXPECTED_VERSION_${_comp} ([0-9]+)" _match "${_header}")
set(_version "${_version}${CMAKE_MATCH_1}.")
endforeach()
string(REGEX REPLACE "\\.$" "" _version "${_version}")
set(${result_var} "${_version}" PARENT_SCOPE)
endfunction()

_zeus_expected_parse_header_version(
"${CMAKE_CURRENT_SOURCE_DIR}/include/zeus/expected.hpp"
_zeus_expected_header_version
)

project(
zeus_expected
VERSION 1.3.3
VERSION ${_zeus_expected_header_version}
DESCRIPTION "Backporting std::expected to C++17."
HOMEPAGE_URL "https://github.com/zeus-cpp/expected"
LANGUAGES CXX
)

unset(_zeus_expected_header_version)

add_library(${PROJECT_NAME} INTERFACE)
add_library(zeus::expected ALIAS ${PROJECT_NAME})

Expand Down
2 changes: 1 addition & 1 deletion include/zeus/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define ZEUS_EXPECTED_VERSION_MAJOR 1
#define ZEUS_EXPECTED_VERSION_MINOR 3
#define ZEUS_EXPECTED_VERSION_PATCH 3
#define ZEUS_EXPECTED_VERSION_PATCH 4

#if defined(_MSVC_LANG)
#define ZEUS_EXPECTED_CPLUSPLUS _MSVC_LANG
Expand Down
Loading