Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved definitions into a config #3479

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ lib/
metastore_db

plugin/updater_gpu/test/cpp/data
/include/xgboost/build_config.h
32 changes: 19 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -50,25 +52,27 @@ 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
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
Expand Down Expand Up @@ -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 "")
Expand All @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions cmake/build_config.h.in
Original file line number Diff line number Diff line change
@@ -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_


1 change: 1 addition & 0 deletions include/xgboost/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef XGBOOST_BASE_H_
#define XGBOOST_BASE_H_

#include <dmlc/build_config.h>
#include <dmlc/base.h>
#include <dmlc/omp.h>
#include <cmath>
Expand Down