Commit 8de46283 authored by Dominik Charousset's avatar Dominik Charousset

Read version from config.hpp, delete VERSION file

parent 7b86aa08
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(caf C CXX) project(caf C CXX)
# extract version from VERSION file # read content of config.hpp
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" CAF_VERSION LIMIT_COUNT 1) file(READ "libcaf_core/caf/config.hpp" CONFIG_HPP)
string(REPLACE "." " " version_numbers ${CAF_VERSION}) # get line containing the version
separate_arguments(version_numbers) string(REGEX MATCH "#define CAF_VERSION [0-9]+" VERSION_LINE "${CONFIG_HPP}")
list(GET version_numbers 0 CAF_VERSION_MAJOR) # extract version number from line
list(GET version_numbers 1 CAF_VERSION_MINOR) string(REGEX MATCH "[0-9]+" VERSION_INT "${VERSION_LINE}")
list(GET version_numbers 2 CAF_VERSION_PATCH) # calculate major, minor, and patch version
math(EXPR CAF_VERSION_MAJOR "${VERSION_INT} / 10000")
math(EXPR CAF_VERSION_MINOR "( ${VERSION_INT} / 100) % 100")
math(EXPR CAF_VERSION_PATCH "${VERSION_INT} % 100")
# create full version string
set(CAF_VERSION "${CAF_VERSION_MAJOR}.${CAF_VERSION_MINOR}.${CAF_VERSION_PATCH}")
# prohibit in-source builds # prohibit in-source builds
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
*/ */
#define CAF_VERSION 1001 #define CAF_VERSION 1001
#define CAF_MAJOR_VERSION (CAF_VERSION / 100000) #define CAF_MAJOR_VERSION (CAF_VERSION / 10000)
#define CAF_MINOR_VERSION ((CAF_VERSION / 100) % 1000) #define CAF_MINOR_VERSION ((CAF_VERSION / 100) % 100)
#define CAF_PATCH_VERSION (CAF_VERSION % 100) #define CAF_PATCH_VERSION (CAF_VERSION % 100)
// sets CAF_DEPRECATED, CAF_ANNOTATE_FALLTHROUGH, // sets CAF_DEPRECATED, CAF_ANNOTATE_FALLTHROUGH,
...@@ -48,22 +48,22 @@ ...@@ -48,22 +48,22 @@
#if defined(__clang__) #if defined(__clang__)
# define CAF_CLANG # define CAF_CLANG
# define CAF_DEPRECATED __attribute__((__deprecated__)) # define CAF_DEPRECATED __attribute__((__deprecated__))
# define CAF_PUSH_WARNINGS \ # define CAF_PUSH_WARNINGS \
_Pragma("clang diagnostic push") \ _Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wall\"") \ _Pragma("clang diagnostic ignored \"-Wall\"") \
_Pragma("clang diagnostic ignored \"-Wextra\"") \ _Pragma("clang diagnostic ignored \"-Wextra\"") \
_Pragma("clang diagnostic ignored \"-Werror\"") \ _Pragma("clang diagnostic ignored \"-Werror\"") \
_Pragma("clang diagnostic ignored \"-Wdeprecated\"") \ _Pragma("clang diagnostic ignored \"-Wdeprecated\"") \
_Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \ _Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \
_Pragma("clang diagnostic ignored \"-Wextra-semi\"") \ _Pragma("clang diagnostic ignored \"-Wextra-semi\"") \
_Pragma("clang diagnostic ignored \"-Wdocumentation\"") \ _Pragma("clang diagnostic ignored \"-Wdocumentation\"") \
_Pragma("clang diagnostic ignored \"-Wweak-vtables\"") \ _Pragma("clang diagnostic ignored \"-Wweak-vtables\"") \
_Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \ _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
_Pragma("clang diagnostic ignored \"-Wswitch-enum\"") \ _Pragma("clang diagnostic ignored \"-Wswitch-enum\"") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \ _Pragma("clang diagnostic ignored \"-Wshadow\"") \
_Pragma("clang diagnostic ignored \"-Wconversion\"") \ _Pragma("clang diagnostic ignored \"-Wconversion\"") \
_Pragma("clang diagnostic ignored \"-Wcast-align\"") \ _Pragma("clang diagnostic ignored \"-Wcast-align\"") \
_Pragma("clang diagnostic ignored \"-Wundef\"") \ _Pragma("clang diagnostic ignored \"-Wundef\"") \
_Pragma("clang diagnostic ignored \"-Wnested-anon-types\"") _Pragma("clang diagnostic ignored \"-Wnested-anon-types\"")
# define CAF_POP_WARNINGS \ # define CAF_POP_WARNINGS \
_Pragma("clang diagnostic pop") _Pragma("clang diagnostic pop")
...@@ -124,26 +124,24 @@ using ::backtrace_symbols_fd; ...@@ -124,26 +124,24 @@ using ::backtrace_symbols_fd;
#endif #endif
#ifdef CAF_ENABLE_RUNTIME_CHECKS #ifdef CAF_ENABLE_RUNTIME_CHECKS
# define CAF_REQUIRE__(stmt, file, line) \ # define CAF_REQUIRE__(stmt, file, line) \
printf("%s:%u: requirement failed '%s'\n", file, line, stmt); \ printf("%s:%u: requirement failed '%s'\n", file, line, stmt); { \
{ \ void* array[10]; \
void* array[10]; \ auto caf_bt_size = ::caf::detail::backtrace(array, 10); \
auto caf_bt_size = ::caf::detail::backtrace(array, 10); \ ::caf::detail::backtrace_symbols_fd(array, caf_bt_size, 2); \
::caf::detail::backtrace_symbols_fd(array, caf_bt_size, 2); \ } abort()
} \ # define CAF_REQUIRE(stmt) \
abort() if (static_cast<bool>(stmt) == false) { \
# define CAF_REQUIRE(stmt) \ CAF_REQUIRE__(#stmt, __FILE__, __LINE__); \
if (static_cast<bool>(stmt) == false) { \ } static_cast<void>(0)
CAF_REQUIRE__(#stmt, __FILE__, __LINE__); \
}((void) 0)
#else #else
# define CAF_REQUIRE(unused) static_cast<void>(0) # define CAF_REQUIRE(unused) static_cast<void>(0)
#endif #endif
#define CAF_CRITICAL__(error, file, line) { \ #define CAF_CRITICAL__(error, file, line) { \
printf("%s:%u: critical error: '%s'\n", file, line, error); \ printf("%s:%u: critical error: '%s'\n", file, line, error); \
exit(7); \ exit(7); \
} ((void) 0) } static_cast<void>(0)
#define CAF_CRITICAL(error) CAF_CRITICAL__(error, __FILE__, __LINE__) #define CAF_CRITICAL(error) CAF_CRITICAL__(error, __FILE__, __LINE__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment