emscripten-core / emscripten-core/emscripten
emcmake error: "Failed to find emscripten cache directory"
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
When building a project with ```emcmake cmake``` (version 2.0.25 of emscripten, version 3.21 of cmake) I am getting very strange errors, such as:
```
CMake Error at /home/brian/dev/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake:217 (message):
Failed to find emscripten cache directory with command
"'/home/brian/dev/emsdk/upstream/emscripten/em-config' CACHE"! Process
returned with error code 0.
Call Stack (most recent call first):
/home/brian/.local/share/cmake-3.21/Modules/CMakeCXXInformation.cmake:65 (include)
config/cmake_ext_mod/HDFUseCXX.cmake:16 (ENABLE_LANGUAGE)
CMakeLists.txt:1117 (include)
```
It seems strange that in emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake the RESULT_VARIABLE from ```execute_process``` is being checked with ```EQUAL 0```, but the error message indicates that the result variable was indeed 0 (see output above).
I was able to fix the problem by changing all three such instances of ```EQUAL 0``` to ```EQUAL "0"```, and compilation completes perfectly, but I can't find a discussion online of which form (string or number) of 0 you are supposed to use here.
To make things more confusing, this doesn't happen every time (for instance if compiling C but not C++, it doesn't seem to have a problem).
EDIT: looking at the source for [execute_process](https://github.com/Kitware/CMake/blob/master/Source/cmExecuteProcessCommand.cxx), it looks like RESULT_VARIABLE is internally handled as a string in cmake.
Contributor guide
Assessment
This issue has not been assessed yet.