build: resolve cmake executable at configuration time#319
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves local developer experience by making the CMake invocation in multik-openblas Gradle tasks robust to missing PATH entries when Gradle is launched from GUI IDEs (notably on macOS), by resolving the cmake executable to a usable path up front.
Changes:
- Add a
CmakeDetectionhelper inbuildSrcthat selects acmakeexecutable from$CMAKE,$PATH, or common install locations. - Update the CMake
Exectasks to use the resolved executable instead of hardcoding"cmake".
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
buildSrc/src/main/kotlin/org/jetbrains/kotlinx/multik/builds/CmakeDetection.kt |
Introduces cmake discovery logic (env/PATH/common locations) for more reliable Exec execution. |
buildSrc/src/main/kotlin/multik.cmake-build.gradle.kts |
Switches CMake task invocations to use CmakeDetection.executable. |
622d351 to
8f2411d
Compare
devcrocod
added a commit
that referenced
this pull request
Apr 21, 2026
Address Copilot review nits on #319: - `File.canExecute()` alone returns true for directories with +x on POSIX, so a directory named `cmake` under a PATH entry (or in common install locations) could be incorrectly selected. Require `isFile && canExecute()`. - A relative `$CMAKE` value (e.g. `./cmake-wrapper`) was returned as-is, contradicting the "absolute path" KDoc. Normalize all detected candidates via `absolutePath`.
GUI-launched IDEs on macOS don't inherit Homebrew's /opt/homebrew/bin PATH,
so the configure/compile Exec tasks invoking `commandLine("cmake", ...)`
can fail with "Cannot run program 'cmake'" even when cmake is installed.
Resolve an absolute cmake path at configuration time via CmakeDetection:
check $CMAKE env var, scan $PATH, then fall back to common install paths
for macOS/Linux/Windows.
Address Copilot review nits on #319: - `File.canExecute()` alone returns true for directories with +x on POSIX, so a directory named `cmake` under a PATH entry (or in common install locations) could be incorrectly selected. Require `isFile && canExecute()`. - A relative `$CMAKE` value (e.g. `./cmake-wrapper`) was returned as-is, contradicting the "absolute path" KDoc. Normalize all detected candidates via `absolutePath`.
d620cb0 to
c54c17a
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
/opt/homebrew/bininPATH. Theconfigure_cmake/compile_cmakeExec tasks invokecommandLine("cmake", ...)and fail withCannot run program 'cmake', even when cmake is installed.cmakebinary to an absolute path at configuration time via a newCmakeDetectionhelper:$CMAKEenv var, if set and executable.$PATHfor thecmake(orcmake.exe) binary./opt/homebrew/bin,/usr/local/bin,/usr/bin,C:\Program Files\CMake\bin\cmake.exe, …)."cmake"(preserves current behaviour on unusual setups).multik.cmake-build.gradle.ktsto use the resolved executable everywhere.No behaviour change for CI (
gcc/cmakeare on PATH there); fixes the "works in terminal, fails in IDE" gotcha locally.Test plan
./gradlew :multik-openblas:build_cmakefrom a terminal shell — still works.:multik-openblas:build_cmake— previously failed, now picks up/opt/homebrew/bin/cmake.CMAKE=/some/other/cmake ./gradlew :multik-openblas:configureCmake— honours the env override.