-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[cmake] consolidate set_target_properties() calls #6594
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -272,8 +272,12 @@ if(USE_CUDA) | |
|
||
function(add_histogram hsize hname hadd hconst hdir) | ||
add_library(histo${hsize}${hname} OBJECT src/treelearner/kernels/histogram${hsize}.cu) | ||
set_target_properties(histo${hsize}${hname} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) | ||
set_target_properties(histo${hsize}${hname} PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) | ||
set_target_properties( | ||
histo${hsize}${hname} | ||
PROPERTIES | ||
CUDA_SEPARABLE_COMPILATION ON | ||
CUDA_ARCHITECTURES ${CUDA_ARCHS} | ||
) | ||
if(hadd) | ||
list(APPEND histograms histo${hsize}${hname}) | ||
set(histograms ${histograms} PARENT_SCOPE) | ||
|
@@ -539,10 +543,14 @@ if(USE_SWIG) | |
set_property(SOURCE swig/lightgbmlib.i PROPERTY SWIG_FLAGS "${swig_options}") | ||
swig_add_library(_lightgbm_swig LANGUAGE java SOURCES swig/lightgbmlib.i) | ||
swig_link_libraries(_lightgbm_swig _lightgbm) | ||
# 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 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") | ||
set_target_properties( | ||
_lightgbm_swig | ||
PROPERTIES | ||
# needed to ensure Linux build does not have lib prefix specified twice, e.g. liblib_lightgbm_swig | ||
PREFIX "" | ||
# needed in some versions of CMake for VS and MinGW builds to ensure output dll has lib prefix | ||
OUTPUT_NAME "lib_lightgbm_swig" | ||
) | ||
if(WIN32) | ||
if(MINGW OR CYGWIN) | ||
add_custom_command( | ||
|
@@ -655,20 +663,29 @@ if(__INTEGRATE_OPENCL) | |
endif() | ||
|
||
if(USE_CUDA) | ||
set_target_properties(lightgbm_objs PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) | ||
set_target_properties(_lightgbm PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) | ||
if(BUILD_CLI) | ||
set_target_properties(lightgbm PROPERTIES CUDA_ARCHITECTURES ${CUDA_ARCHS}) | ||
endif() | ||
|
||
set_target_properties(lightgbm_objs PROPERTIES CUDA_SEPARABLE_COMPILATION ON) | ||
set_target_properties( | ||
lightgbm_objs | ||
PROPERTIES | ||
CUDA_ARCHITECTURES ${CUDA_ARCHS} | ||
CUDA_SEPARABLE_COMPILATION ON | ||
) | ||
|
||
set_target_properties( | ||
_lightgbm | ||
PROPERTIES | ||
CUDA_ARCHITECTURES ${CUDA_ARCHS} | ||
CUDA_RESOLVE_DEVICE_SYMBOLS ON | ||
) | ||
|
||
# Device linking is not supported for object libraries. | ||
# Thus we have to specify them on final targets. | ||
if(BUILD_CLI) | ||
set_target_properties(lightgbm PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
set_target_properties( | ||
lightgbm | ||
PROPERTIES | ||
CUDA_ARCHITECTURES ${CUDA_ARCHS} | ||
CUDA_RESOLVE_DEVICE_SYMBOLS ON | ||
) | ||
endif() | ||
set_target_properties(_lightgbm PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
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. This line was lost in new config. 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. ah! Too many similarly-named properties 😂 Thank you for catching this, I've fixed that in recent commits. |
||
|
||
# histograms are list of object libraries. Linking object library to other | ||
# object libraries only gets usage requirements, the linked objects won't be | ||
|
Oops, something went wrong.
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.
CUDA_SEPARABLE_COMPILATION
was not set for_lightgbm
target in previous config.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.
ah! Thank you for catching that, I've updated it in recent commits.
This also led me to question what this property actually does. Here's a simple explanation of it: https://stackoverflow.com/a/50557765/3986677