Use configure_file() to configure version only (#4974)
* Avoid writing build_config.h * Remove build_config.h all together. * Lint.
This commit is contained in:
parent
5b1715d97c
commit
f24be2efb4
@ -1,8 +1,8 @@
|
||||
function (write_version)
|
||||
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
|
||||
configure_file(
|
||||
${xgboost_SOURCE_DIR}/cmake/build_config.h.in
|
||||
${xgboost_SOURCE_DIR}/include/xgboost/build_config.h @ONLY)
|
||||
${xgboost_SOURCE_DIR}/cmake/version_config.h.in
|
||||
${xgboost_SOURCE_DIR}/include/xgboost/version_config.h @ONLY)
|
||||
configure_file(
|
||||
${xgboost_SOURCE_DIR}/cmake/Python_version.in
|
||||
${xgboost_SOURCE_DIR}/python-package/xgboost/VERSION
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
/*!
|
||||
* Copyright 2019 by Contributors
|
||||
* \file build_config.h
|
||||
*
|
||||
* Generated from `cmake/build_config.h.in` by cmake.
|
||||
*/
|
||||
#ifndef XGBOOST_BUILD_CONFIG_H_
|
||||
#define XGBOOST_BUILD_CONFIG_H_
|
||||
|
||||
#cmakedefine XGBOOST_MM_PREFETCH_PRESENT
|
||||
#cmakedefine XGBOOST_BUILTIN_PREFETCH_PRESENT
|
||||
|
||||
#define XGBOOST_VER_MAJOR @xgboost_VERSION_MAJOR@
|
||||
#define XGBOOST_VER_MINOR @xgboost_VERSION_MINOR@
|
||||
#define XGBOOST_VER_PATCH @xgboost_VERSION_PATCH@
|
||||
|
||||
#endif // XGBOOST_BUILD_CONFIG_H_
|
||||
11
cmake/version_config.h.in
Normal file
11
cmake/version_config.h.in
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Copyright 2019 XGBoost contributors
|
||||
*/
|
||||
#ifndef XGBOOST_VERSION_CONFIG_H_
|
||||
#define XGBOOST_VERSION_CONFIG_H_
|
||||
|
||||
#define XGBOOST_VER_MAJOR @xgboost_VERSION_MAJOR@
|
||||
#define XGBOOST_VER_MINOR @xgboost_VERSION_MINOR@
|
||||
#define XGBOOST_VER_PATCH @xgboost_VERSION_PATCH@
|
||||
|
||||
#endif // XGBOOST_VERSION_CONFIG_H_
|
||||
@ -84,6 +84,20 @@
|
||||
#define XGBOOST_DEVICE
|
||||
#endif // defined (__CUDA__) || defined(__NVCC__)
|
||||
|
||||
// These check are for Makefile.
|
||||
#if !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined(XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
/* default logic for software pre-fetching */
|
||||
#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))) || defined(__INTEL_COMPILER)
|
||||
// Enable _mm_prefetch for Intel compiler and MSVC+x86
|
||||
#define XGBOOST_MM_PREFETCH_PRESENT
|
||||
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
|
||||
#elif defined(__GNUC__)
|
||||
// Enable __builtin_prefetch for GCC
|
||||
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
|
||||
#endif // GUARDS
|
||||
|
||||
#endif // !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined()
|
||||
|
||||
/*! \brief namespace of xgboost*/
|
||||
namespace xgboost {
|
||||
/*!
|
||||
@ -232,7 +246,4 @@ using XGBoostVersionT = int32_t;
|
||||
#endif // DMLC_USE_CXX11 && defined(__GNUC__) && !defined(__clang_version__)
|
||||
} // namespace xgboost
|
||||
|
||||
/* Always keep this #include at the bottom of xgboost/base.h */
|
||||
#include <xgboost/build_config.h>
|
||||
|
||||
#endif // XGBOOST_BASE_H_
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
/*!
|
||||
* Copyright 2019 by Contributors
|
||||
* \file build_config.h
|
||||
*
|
||||
* Generated from `cmake/build_config.h.in` by cmake.
|
||||
*/
|
||||
#ifndef XGBOOST_BUILD_CONFIG_H_
|
||||
#define XGBOOST_BUILD_CONFIG_H_
|
||||
|
||||
// These check are for Makefile.
|
||||
#if !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined(XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
/* default logic for software pre-fetching */
|
||||
#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))) || defined(__INTEL_COMPILER)
|
||||
// Enable _mm_prefetch for Intel compiler and MSVC+x86
|
||||
#define XGBOOST_MM_PREFETCH_PRESENT
|
||||
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
|
||||
#elif defined(__GNUC__)
|
||||
// Enable __builtin_prefetch for GCC
|
||||
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
|
||||
#endif // GUARDS
|
||||
|
||||
#endif // !defined(XGBOOST_MM_PREFETCH_PRESENT) && !defined()
|
||||
|
||||
#define XGBOOST_VER_MAJOR 1
|
||||
#define XGBOOST_VER_MINOR 0
|
||||
#define XGBOOST_VER_PATCH 0
|
||||
|
||||
#endif // XGBOOST_BUILD_CONFIG_H_
|
||||
11
include/xgboost/version_config.h
Normal file
11
include/xgboost/version_config.h
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Copyright 2019 XGBoost contributors
|
||||
*/
|
||||
#ifndef XGBOOST_VERSION_CONFIG_H_
|
||||
#define XGBOOST_VERSION_CONFIG_H_
|
||||
|
||||
#define XGBOOST_VER_MAJOR 1
|
||||
#define XGBOOST_VER_MINOR 0
|
||||
#define XGBOOST_VER_PATCH 0
|
||||
|
||||
#endif // XGBOOST_VERSION_CONFIG_H_
|
||||
@ -64,6 +64,17 @@ target_compile_definitions(objxgboost
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:_MWAITXINTRIN_H_INCLUDED>
|
||||
${XGBOOST_DEFINITIONS})
|
||||
|
||||
if (XGBOOST_MM_PREFETCH_PRESENT)
|
||||
target_compile_definitions(objxgboost
|
||||
PRIVATE
|
||||
-DXGBOOST_MM_PREFETCH_PRESENT=1)
|
||||
endif(XGBOOST_MM_PREFETCH_PRESENT)
|
||||
if (XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
target_compile_definitions(objxgboost
|
||||
PRIVATE
|
||||
-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1)
|
||||
endif (XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
|
||||
if (USE_OPENMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
if (OpenMP_CXX_FOUND OR OPENMP_FOUND)
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
// Copyright (c) 2014-2019 by Contributors
|
||||
|
||||
#include <xgboost/data.h>
|
||||
#include <xgboost/learner.h>
|
||||
#include <xgboost/c_api.h>
|
||||
#include <xgboost/logging.h>
|
||||
|
||||
#include <dmlc/thread_local.h>
|
||||
#include <rabit/rabit.h>
|
||||
#include <rabit/c_api.h>
|
||||
@ -16,6 +10,12 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "xgboost/data.h"
|
||||
#include "xgboost/learner.h"
|
||||
#include "xgboost/c_api.h"
|
||||
#include "xgboost/logging.h"
|
||||
#include "xgboost/version_config.h"
|
||||
|
||||
#include "c_api_error.h"
|
||||
#include "../data/simple_csr_source.h"
|
||||
#include "../common/math.h"
|
||||
|
||||
@ -2,14 +2,16 @@
|
||||
* Copyright 2017-2019 by Contributors
|
||||
* \file hist_util.cc
|
||||
*/
|
||||
#include "./hist_util.h"
|
||||
#include <dmlc/timer.h>
|
||||
#include <rabit/rabit.h>
|
||||
#include <dmlc/omp.h>
|
||||
|
||||
#include <rabit/rabit.h>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
#include "xgboost/base.h"
|
||||
#include "../common/common.h"
|
||||
#include "./hist_util.h"
|
||||
#include "./random.h"
|
||||
#include "./column_matrix.h"
|
||||
#include "./quantile.h"
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include "xgboost/logging.h"
|
||||
#include "xgboost/json.h"
|
||||
#include "xgboost/version_config.h"
|
||||
#include "version.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
@ -2,15 +2,16 @@
|
||||
* Copyright 2015-2019 by Contributors
|
||||
* \file data.cc
|
||||
*/
|
||||
#include <xgboost/data.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include <xgboost/build_config.h>
|
||||
#include <dmlc/registry.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "./sparse_page_writer.h"
|
||||
#include "./simple_dmatrix.h"
|
||||
#include "./simple_csr_source.h"
|
||||
#include "xgboost/data.h"
|
||||
#include "xgboost/logging.h"
|
||||
#include "xgboost/version_config.h"
|
||||
#include "sparse_page_writer.h"
|
||||
#include "simple_dmatrix.h"
|
||||
#include "simple_csr_source.h"
|
||||
|
||||
#include "../common/io.h"
|
||||
#include "../common/version.h"
|
||||
#include "../common/group_data.h"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Copyright by Contributors
|
||||
// Copyright (c) 2019 by Contributors
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/version_config.h>
|
||||
#include <xgboost/c_api.h>
|
||||
#include <xgboost/data.h>
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include <dmlc/filesystem.h>
|
||||
#include <dmlc/io.h>
|
||||
|
||||
#include <xgboost/version_config.h>
|
||||
#include <xgboost/json.h>
|
||||
#include <xgboost/base.h>
|
||||
|
||||
@ -58,4 +59,4 @@ TEST(Version, Basic) {
|
||||
str = str.substr(ptr);
|
||||
ASSERT_EQ(str.size(), 0);
|
||||
}
|
||||
} // namespace xgboost
|
||||
} // namespace xgboost
|
||||
|
||||
@ -2,9 +2,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vector>
|
||||
#include "helpers.h"
|
||||
#include <dmlc/filesystem.h>
|
||||
|
||||
#include "xgboost/learner.h"
|
||||
#include "dmlc/filesystem.h"
|
||||
#include <xgboost/learner.h>
|
||||
#include <xgboost/version_config.h>
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user