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

[cmake] stop using file(GLOB) #6588

Merged
merged 4 commits into from
Aug 6, 2024
Merged

[cmake] stop using file(GLOB) #6588

merged 4 commits into from
Aug 6, 2024

Conversation

jameslamb
Copy link
Collaborator

Proposes the following changes to CMake files here:

  • using variable name LGBM_SOURCES instead of SOURCES
    • (to reduce the risk of possible conflicts with CMake... "SOURCES" is just a very generic name and I could see it having a special meaning in CMake in the future)
  • explicitly listing sources instead of using file(GLOB)

Notes for Reviewers

Why explicitly list sources?

  • reduces the risk of accidentally including files from local development that shouldn't be included
  • helps CMake to detect when it needs to change the generated build system

This is explicitly recommended in the CMake docs for file() (link).

Note We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.

More discussion about this topic:

I feel the set of files in LightGBM is small enough, and changes infrequently enough, that it's worth doing this in exchange for being more explicit.

@jameslamb jameslamb changed the title WIP: [cmake] stop using file(GLOB) [cmake] stop using file(GLOB) Aug 6, 2024
@jameslamb jameslamb marked this pull request as ready for review August 6, 2024 01:37
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Thanks!
Checked manually that no one file was missed.

@StrikerRUS StrikerRUS merged commit ff2c62a into master Aug 6, 2024
45 checks passed
@StrikerRUS StrikerRUS deleted the cmake-cleanup branch August 6, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants