Skip to content

[cmake] stop using file(GLOB) - #6588

Merged
StrikerRUS merged 4 commits into
masterfrom
cmake-cleanup
Aug 6, 2024
Merged

StrikerRUS merged 4 commits into
masterfrom
cmake-cleanup

Conversation

@jameslamb

Copy link
Copy Markdown
Member

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

@StrikerRUS StrikerRUS left a comment •

Copy link
Copy Markdown
Collaborator

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
@StrikerRUS
StrikerRUS deleted the cmake-cleanup branch August 6, 2024 15:30
@github-actions

github-actions Bot commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants