Skip to content

Commit c7b8e3f

Browse files
authored
Check if cmake is on the PATH in emcmake.py (#22489)
Currently, users who run emcmake without cmake on the PATH are greeted with confusing errors like: ``` emcmake cmake .. configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=D:\src\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=D:/src/emsdk/node/18.20.3_64bit/bin/node.exe -G Ninja emcmake: error: 'cmake .. -DCMAKE_TOOLCHAIN_FILE=D:\src\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=D:/src/emsdk/node/18.20.3_64bit/bin/node.exe -G Ninja' failed: [WinError 2] The system cannot find the file specified ```
1 parent 3364d20 commit c7b8e3f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

emcmake.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def has_substr(args, substr):
4545
# See https://github.com/emscripten-core/emscripten/issues/15522
4646
args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}')
4747

48+
# Print a better error if we have no CMake executable on the PATH
49+
if not os.path.dirname(args[0]) and not shutil.which(args[0]):
50+
print(f'emcmake: cmake executable not found on PATH: `{args[0]}`', file=sys.stderr)
51+
return 1
52+
4853
# On Windows specify MinGW Makefiles or ninja if we have them and no other
4954
# toolchain was specified, to keep CMake from pulling in a native Visual
5055
# Studio, or Unix Makefiles.

0 commit comments

Comments
 (0)