fix: Fix thread issue in CMakeLists for Android#6
fix: Fix thread issue in CMakeLists for Android#6ajeetsinghyadav wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a missing find_package(Threads REQUIRED) call in src/CMakeLists.txt that was causing a CMake configuration error on Android (and potentially other non-Windows/non-Emscripten platforms) when src/CMakeLists.txt was processed without the necessary Threads package being available. It also updates the comment on the platform-specific linking block for clarity.
Changes:
- Added
find_package(Threads REQUIRED)inside theif(NOT WIN32 AND NOT EMSCRIPTEN)guard insrc/CMakeLists.txt. - Updated the inline comment to say "portable across toolchains" instead of "portable for pthread".
| # Platform-specific library linking (Threads::Threads is portable for pthread) | ||
| # Platform-specific library linking (Threads::Threads is portable across toolchains) | ||
| if(NOT WIN32 AND NOT EMSCRIPTEN) | ||
| find_package(Threads REQUIRED) |
There was a problem hiding this comment.
The find_package(Threads REQUIRED) call added here is redundant. The root CMakeLists.txt already calls find_package(Threads REQUIRED) unconditionally at line 250, immediately before add_subdirectory(src). Because src/CMakeLists.txt is always processed via that add_subdirectory, the Threads package is guaranteed to be found before this file is evaluated.
Additionally, placing find_package inside a platform-conditional block (if(NOT WIN32 AND NOT EMSCRIPTEN)) is a subtle inconsistency: the find call is now skipped on Windows/Emscripten, while the root always finds it. If this block is the authoritative location for the find_package call in the future (e.g., if the root-level call is removed), Windows and Emscripten builds would silently skip finding Threads, which could cause issues if Threads::Threads is ever referenced elsewhere from this file.
The find_package(Threads REQUIRED) should be removed from src/CMakeLists.txt, since the root CMakeLists.txt already handles it. If src/CMakeLists.txt must remain self-contained, the find_package should be placed unconditionally at the top of the file, not nested inside the platform guard.
| find_package(Threads REQUIRED) |
No description provided.