From 7757145668deb472743d8f7cd0039196138ebd76 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Tue, 17 Jul 2018 13:49:40 +0300 Subject: [PATCH] Moved definitions into a config --- .gitignore | 1 + CMakeLists.txt | 32 +++++++++++++++++++------------- cmake/build_config.h.in | 15 +++++++++++++++ include/xgboost/base.h | 1 + 4 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 cmake/build_config.h.in diff --git a/.gitignore b/.gitignore index bdfa3322a55a..5131e198399a 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,4 @@ lib/ metastore_db plugin/updater_gpu/test/cpp/data +/include/xgboost/build_config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 24eda97aa507..46bba5b6dd3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.2) project(xgboost) -include(cmake/Utils.cmake) + +set(CMAKE_LOCAL "${PROJECT_SOURCE_DIR}/cmake") +include(${CMAKE_LOCAL}/Utils.cmake) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") find_package(OpenMP) @@ -50,7 +52,7 @@ if(USE_AVX) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") endif() - add_definitions(-DXGBOOST_USE_AVX) + add_definitions(-D) endif() # enable custom logging @@ -58,17 +60,19 @@ add_definitions(-DDMLC_LOG_CUSTOMIZE=1) # compiled code customizations for R package if(R_LIB) - add_definitions( - -DXGBOOST_STRICT_R_MODE=1 - -DXGBOOST_CUSTOMIZE_GLOBAL_PRNG=1 - -DDMLC_LOG_BEFORE_THROW=0 - -DDMLC_DISABLE_STDIN=1 - -DDMLC_LOG_CUSTOMIZE=1 - -DRABIT_CUSTOMIZE_MSG_ - -DRABIT_STRICT_CXX98_ - ) + set(XGBOOST_STRICT_R_MODE 1) + set(XGBOOST_STRICT_R_MODE 1) + set(XGBOOST_CUSTOMIZE_GLOBAL_PRNG 1) + set(DMLC_LOG_BEFORE_THROW 0) + set(DMLC_DISABLE_STDIN 1) + set(DMLC_LOG_CUSTOMIZE 1) + set(DMLC_LOG_CUSTOMIZE 1) + set(RABIT_CUSTOMIZE_MSG_ 1) + set(RABIT_STRICT_CXX98_ 1) endif() +set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include") +set(XGBOOST_INCLUDE_DIR "${INCLUDE_DIR}/xgboost") include_directories ( ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/dmlc-core/include @@ -118,14 +122,14 @@ if(USE_CUDA) find_package(CUDA 8.0 REQUIRED) cmake_minimum_required(VERSION 3.5) - add_definitions(-DXGBOOST_USE_CUDA) + set(XGBOOST_USE_CUDA 1) include_directories(cub) if(USE_NCCL) find_package(Nccl REQUIRED) include_directories(${NCCL_INCLUDE_DIR}) - add_definitions(-DXGBOOST_USE_NCCL) + set(XGBOOST_USE_NCCL 1) endif() set(GENCODE_FLAGS "") @@ -146,6 +150,8 @@ if(USE_CUDA) list(APPEND LINK_LIBRARIES gpuxgboost) endif() +message(STATUS "creating config: ${CMAKE_LOCAL}/build_config.h.in -> ${XGBOOST_INCLUDE_DIR}/build_config.h") +configure_file("${CMAKE_LOCAL}/build_config.h.in" "${XGBOOST_INCLUDE_DIR}/build_config.h") # flags and sources for R-package if(R_LIB) diff --git a/cmake/build_config.h.in b/cmake/build_config.h.in new file mode 100644 index 000000000000..5794a30ca7d7 --- /dev/null +++ b/cmake/build_config.h.in @@ -0,0 +1,15 @@ +#cmakedefine01 XGBOOST_USE_AVX +#cmakedefine01 XGBOOST_STRICT_R_MODE +#cmakedefine01 XGBOOST_CUSTOMIZE_GLOBAL_PRNG +#cmakedefine XGBOOST_USE_CUDA +#cmakedefine XGBOOST_USE_NCCL + +#cmakedefine01 DMLC_LOG_CUSTOMIZE +#cmakedefine01 DMLC_LOG_BEFORE_THROW +#cmakedefine01 DMLC_DISABLE_STDIN +#cmakedefine01 DMLC_LOG_CUSTOMIZE + +#cmakedefine RABIT_CUSTOMIZE_MSG_ +#cmakedefine RABIT_STRICT_CXX98_ + + diff --git a/include/xgboost/base.h b/include/xgboost/base.h index 3a2a10dbdf07..d483da684592 100644 --- a/include/xgboost/base.h +++ b/include/xgboost/base.h @@ -6,6 +6,7 @@ #ifndef XGBOOST_BASE_H_ #define XGBOOST_BASE_H_ +#include #include #include #include