-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[R-package] [ci] Fix failures with R 3.6 and CMake (fixes #3469) #3541
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
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) | ||
OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) | ||
OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) | ||
OPTION(USE_CUDA "Enable CUDA-accelerated training (EXPERIMENTAL)" OFF) | ||
OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) | ||
OPTION(BUILD_STATIC_LIB "Build static library" OFF) | ||
OPTION(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) | ||
OPTION(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF) | ||
|
||
if(__INTEGRATE_OPENCL) | ||
cmake_minimum_required(VERSION 3.11) | ||
elseif(USE_GPU OR APPLE) | ||
cmake_minimum_required(VERSION 3.2) | ||
elseif(USE_CUDA) | ||
cmake_minimum_required(VERSION 3.16) | ||
elseif(__BUILD_FOR_R) | ||
cmake_minimum_required(VERSION 3.6) | ||
else() | ||
cmake_minimum_required(VERSION 3.0) | ||
endif() | ||
|
||
if(__BUILD_FOR_R) | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") | ||
endif(__BUILD_FOR_R) | ||
|
||
if(USE_CUDA) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this down here because |
||
PROJECT(lightgbm LANGUAGES C CXX CUDA) | ||
else() | ||
PROJECT(lightgbm LANGUAGES C CXX) | ||
endif() | ||
|
||
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) | ||
OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) | ||
OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) | ||
OPTION(USE_CUDA "Enable CUDA-accelerated training (EXPERIMENTAL)" OFF) | ||
OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) | ||
OPTION(BUILD_STATIC_LIB "Build static library" OFF) | ||
OPTION(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) | ||
OPTION(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF) | ||
|
||
if(APPLE) | ||
OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) | ||
endif(APPLE) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that
CMAKE_TRY_COMPILE_TARGET_TYPE
is available only in CMake >= 3.6.https://cmake.org/cmake/help/v3.19/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html
We should add
here, I believe.
LightGBM/CMakeLists.txt
Lines 1 to 9 in 71a1a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok sure! I just added it in 4e21bbd
I also moved all those checks under the
OPTION()
calls. It seemed strange to me that we're doing things likeIF(__INTEGRATE_OPENCL)
(for example) beforeOPTION(__INTEGRATE_OPENCL)
. I think that's a mistake. If you look at https://cmake.org/cmake/help/latest/command/if.html#condition-syntax, it saysI think that
IF(THING_THAT_HAS_NOT_BEEN_DEFINED)
will always evaluate to false.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but it seems that we define "
THING_THAT_HAS_NOT_BEEN_DEFINED
" during passing-DTHING_THAT_HAS_NOT_BEEN_DEFINED
CMake flag. For example, I remember everything was working OK even withoutOPTION
at all: #3144 (comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, makes sense. I think we just got lucky that all options that were used in code before the
OPTION()
calls have default valueOFF
, which behaves the same as it not being defined at all.Anyway, I'm glad that they're all moved to the top now.