diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bddc9553..3d2a454e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,11 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_C_VISIBILITY_PRESET hidden) -set(OQS_VERSION_TEXT "0.11.1-dev") +set(OQS_VERSION_MAJOR 0) +set(OQS_VERSION_MINOR 11) +set(OQS_VERSION_PATCH 1) +set(OQS_VERSION_PRE_RELEASE "-dev") +set(OQS_VERSION_TEXT "${OQS_VERSION_MAJOR}.${OQS_VERSION_MINOR}.${OQS_VERSION_PATCH}${OQS_VERSION_PRE_RELEASE}") set(OQS_COMPILE_BUILD_TARGET "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM}") set(OQS_MINIMAL_GCC_VERSION "7.1.0") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/src/oqsconfig.h.cmake b/src/oqsconfig.h.cmake index dae1babad..7975a5c4a 100644 --- a/src/oqsconfig.h.cmake +++ b/src/oqsconfig.h.cmake @@ -1,6 +1,21 @@ // SPDX-License-Identifier: MIT +/** + * Version of liboqs as a string. Equivalent to {MAJOR}.{MINOR}.{PATCH}{PRE_RELEASE} + */ #cmakedefine OQS_VERSION_TEXT "@OQS_VERSION_TEXT@" +/** + * Version levels of liboqs as integers. + */ +#define OQS_VERSION_MAJOR @OQS_VERSION_MAJOR@ +#define OQS_VERSION_MINOR @OQS_VERSION_MINOR@ +#define OQS_VERSION_PATCH @OQS_VERSION_PATCH@ +/** + * OQS_VERSION_PRE_RELEASE is defined if this is a pre-release version of liboqs, otherwise it is undefined. + * Examples: "-dev" or "-rc1". + */ +#cmakedefine OQS_VERSION_PRE_RELEASE "@OQS_VERSION_PRE_RELEASE@" + #cmakedefine OQS_COMPILE_BUILD_TARGET "@OQS_COMPILE_BUILD_TARGET@" #cmakedefine OQS_DIST_BUILD 1 #cmakedefine OQS_DIST_X86_64_BUILD 1 diff --git a/tests/system_info.c b/tests/system_info.c index 248d377cd..37689dc20 100644 --- a/tests/system_info.c +++ b/tests/system_info.c @@ -219,7 +219,11 @@ static void print_oqs_configuration(void) { * USE_SANITIZER: -fsanitize= option present in compile options * OQS_ENABLE_TEST_CONSTANT_TIME: only shown below */ - printf("OQS version: %s\n", OQS_VERSION_TEXT); +#if defined(OQS_VERSION_PRE_RELEASE) + printf("OQS version: %s (major: %d, minor: %d, patch: %d, pre-release: %s)\n", OQS_VERSION_TEXT, OQS_VERSION_MAJOR, OQS_VERSION_MINOR, OQS_VERSION_PATCH, OQS_VERSION_PRE_RELEASE); +#else + printf("OQS version: %s (major: %d, minor: %d, patch: %d)\n", OQS_VERSION_TEXT, OQS_VERSION_MAJOR, OQS_VERSION_MINOR, OQS_VERSION_PATCH); +#endif #if defined(OQS_COMPILE_GIT_COMMIT) printf("Git commit: %s\n", OQS_COMPILE_GIT_COMMIT); #endif