Specify version macro in CMake. (#4730)

* Specify version macro in CMake.

* Use `XGBOOST_DEFINITIONS` instead.
This commit is contained in:
Jiaming Yuan 2019-08-04 06:04:04 -04:00 committed by GitHub
parent 6edddd7966
commit 4fe0d8203e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -13,6 +13,12 @@ if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "GCC version must be at least 5.0!") message(FATAL_ERROR "GCC version must be at least 5.0!")
endif() endif()
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
set(XGBOOST_DEFINITIONS
${XGBOOST_DEFINITIONS}
-DXGBOOST_VER_MAJOR=${xgboost_VERSION_MAJOR}
-DXGBOOST_VER_MINOR=${xgboost_VERSION_MINOR}
-DXGBOOST_VER_PATCH=${xgboost_VERSION_PATCH})
set_default_configuration_release() set_default_configuration_release()
#-- Options #-- Options

View File

@ -29,6 +29,6 @@ set_target_properties(
CXX_STANDARD_REQUIRED ON CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON) POSITION_INDEPENDENT_CODE ON)
set(XGBOOST_DEFINITIONS ${R_DEFINITIONS} PARENT_SCOPE) set(XGBOOST_DEFINITIONS "${XGBOOST_DEFINITIONS};${R_DEFINITIONS}" PARENT_SCOPE)
set(XGBOOST_OBJ_SOURCES $<TARGET_OBJECTS:xgboost-r> PARENT_SCOPE) set(XGBOOST_OBJ_SOURCES $<TARGET_OBJECTS:xgboost-r> PARENT_SCOPE)
set(LINKED_LIBRARIES_PRIVATE ${LINKED_LIBRARIES_PRIVATE} ${LIBR_CORE_LIBRARY} PARENT_SCOPE) set(LINKED_LIBRARIES_PRIVATE ${LINKED_LIBRARIES_PRIVATE} ${LIBR_CORE_LIBRARY} PARENT_SCOPE)

View File

@ -17,6 +17,14 @@ TEST(Learner, Basic) {
learner->SetParams(args); learner->SetParams(args);
delete mat_ptr; delete mat_ptr;
auto major = XGBOOST_VER_MAJOR;
auto minor = XGBOOST_VER_MINOR;
auto patch = XGBOOST_VER_PATCH;
static_assert(std::is_integral<decltype(major)>::value, "Wrong major version type");
static_assert(std::is_integral<decltype(minor)>::value, "Wrong minor version type");
static_assert(std::is_integral<decltype(patch)>::value, "Wrong patch version type");
} }
TEST(Learner, CheckGroup) { TEST(Learner, CheckGroup) {