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

minor fixes in CMakeLists #2099

Merged
merged 3 commits into from
Apr 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

PROJECT(lightgbm)

OPTION(USE_MPI "MPI based parallel learning" OFF)
OPTION(USE_MPI "Enable MPI-based parallel learning" OFF)
OPTION(USE_OPENMP "Enable OpenMP" ON)
OPTION(USE_GPU "Enable GPU-accelerated training" OFF)
OPTION(USE_SWIG "Enable SWIG to generate Java API" OFF)
Expand All @@ -15,7 +15,7 @@ OPTION(USE_R35 "Set to ON if your R version is not smaller than 3.5" OFF)

if(APPLE)
OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF)
endif()
endif(APPLE)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2")
Expand Down Expand Up @@ -66,13 +66,13 @@ endif(USE_SWIG)

if(USE_R35)
ADD_DEFINITIONS(-DR_VER_ABOVE_35)
endif()
endif(USE_R35)

if(USE_MPI)
find_package(MPI REQUIRED)
ADD_DEFINITIONS(-DUSE_MPI)
MESSAGE(${MPI_LIBRARIES})
MESSAGE(${MPI_CXX_LIBRARIES})
MESSAGE(STATUS "MPI libraries: " ${MPI_LIBRARIES})
MESSAGE(STATUS "MPI C++ libraries: " ${MPI_CXX_LIBRARIES})
else()
ADD_DEFINITIONS(-DUSE_SOCKET)
endif(USE_MPI)
Expand All @@ -82,15 +82,15 @@ if(USE_OPENMP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else()
# Ignore unknown #pragma warning
if( (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]")
OR (CMAKE_CXX_COMPILER_ID MATCHES "[gG][nN][uU]"))
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake uses "GNU" and "Clang" starting from 2.6.0 (maybe earlier) version inside itself:
https://github.com/Kitware/CMake/blob/a00f1beb530c0c9fff8deab150a07b4c3839285b/Modules/CMakeDetermineCCompiler.cmake#L130-L139
https://github.com/Kitware/CMake/blob/a00f1beb530c0c9fff8deab150a07b4c3839285b/Modules/CMakeDetermineCXXCompiler.cmake#L140-L149
And this variable is well-documented starting from version 2.8.10:
https://cmake.org/cmake/help/v2.8.10/cmake.html#variable:CMAKE_LANG_COMPILER_ID
The oldest CMake version supported by LightGBM is 2.8.

The only case for using these regexes can be user-defined compilers, but I think it's not the case we are going to support.
https://stackoverflow.com/a/40653688

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif()
endif(USE_OPENMP)

if(USE_GPU)
SET(BOOST_COMPUTE_HEADER_DIR ${PROJECT_SOURCE_DIR}/compute/include)
include_directories (${BOOST_COMPUTE_HEADER_DIR})
include_directories(${BOOST_COMPUTE_HEADER_DIR})
find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS})
MESSAGE(STATUS "OpenCL include directory:" ${OpenCL_INCLUDE_DIRS})
Expand Down Expand Up @@ -138,7 +138,7 @@ if(MSVC)
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops")
endif()
endif(MSVC)

SET(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include)

Expand Down Expand Up @@ -170,7 +170,7 @@ file(GLOB SOURCES
)

add_executable(lightgbm src/main.cpp ${SOURCES})
add_library(_lightgbm SHARED src/c_api.cpp src/lightgbm_R.cpp ${SOURCES})
add_library(_lightgbm SHARED src/c_api.cpp src/lightgbm_R.cpp ${SOURCES})

if(MSVC)
set_target_properties(_lightgbm PROPERTIES OUTPUT_NAME "lib_lightgbm")
Expand All @@ -182,9 +182,9 @@ if(USE_SWIG)
set_property(SOURCE swig/lightgbmlib.i PROPERTY SWIG_FLAGS "${swig_options}")
swig_add_module(_lightgbm_swig java swig/lightgbmlib.i)
swig_link_libraries(_lightgbm_swig _lightgbm)
# needed to ensure linux build does not have lib specified twice, eg liblib_lightgbm_swig
# needed to ensure Linux build does not have lib prefix specified twice, e.g. liblib_lightgbm_swig
set_target_properties(_lightgbm_swig PROPERTIES PREFIX "")
# needed in latest version of cmake for VS and MINGW builds to ensure output dll has lib prefix
# needed in some versions of CMake for VS and MinGW builds to ensure output dll has lib prefix
set_target_properties(_lightgbm_swig PROPERTIES OUTPUT_NAME "lib_lightgbm_swig")
if(WIN32)
if(MINGW OR CYGWIN)
Expand Down