Fix version numbering in CMakeLists.txt
Fixes #115. Read the version number out of `cxxopts.hpp` instead of having to duplicate it in CMakeLists.txt.
This commit is contained in:
parent
e725ea3084
commit
cde83be99b
@ -12,6 +12,7 @@ options. The project adheres to semantic versioning.
|
||||
### Bug Fixes
|
||||
|
||||
* Fix a warning about possible loss of data.
|
||||
* Fix version numbering in CMakeLists.txt
|
||||
|
||||
## 2.1.1
|
||||
|
||||
|
||||
@ -22,7 +22,16 @@ project(cxxopts)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(VERSION "1.2.0")
|
||||
file(STRINGS "${PROJECT_SOURCE_DIR}/include/cxxopts.hpp" cxxopts_version_defines
|
||||
REGEX "#define {CXXOPTS__VERSION_(MAJOR|MINOR|PATCH)")
|
||||
foreach(ver ${cxxopts_version_defines})
|
||||
if(ver MATCHES "#define {CXXOPTS__VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
|
||||
set({CXXOPTS__VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endforeach()
|
||||
set(VERSION ${CXXOPTS__VERSION_MAJOR}.${CXXOPTS__VERSION_MINOR}.${CXXOPTS__VERSION_PATCH})
|
||||
|
||||
# set(VERSION "1.2.0")
|
||||
|
||||
option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
||||
option(CXXOPTS_BUILD_TESTS "Set to ON to build tests" OFF)
|
||||
|
||||
@ -43,11 +43,19 @@ THE SOFTWARE.
|
||||
#define CXXOPTS_HAS_OPTIONAL
|
||||
#endif
|
||||
|
||||
#define CXXOPTS__VERSION_MAJOR 2
|
||||
#define CXXOPTS__VERSION_MINOR 2
|
||||
#define CXXOPTS__VERSION_PATCH 0
|
||||
|
||||
namespace cxxopts
|
||||
{
|
||||
static constexpr struct {
|
||||
uint8_t major, minor, patch;
|
||||
} version = {2, 1, 0};
|
||||
} version = {
|
||||
CXXOPTS__VERSION_MAJOR,
|
||||
CXXOPTS__VERSION_MINOR,
|
||||
CXXOPTS__VERSION_PATCH
|
||||
};
|
||||
}
|
||||
|
||||
//when we ask cxxopts to use Unicode, help strings are processed using ICU,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user