emscripten-core / emscripten-core/emscripten
can't use CMake function em_link_js_library for cpp project
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Please include the following in your bug report:
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.2-git
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 782c0dd1a1c235afb09a34e7da4a1267ead14765)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/opt/emscripten/libexec/llvm/bin
```
**Failing command line in full:**
`emcmake cmake .`
**Full link command and output with `-v` appended:**
```
~> cat CMakeLists.txt
cmake_minimum_required (VERSION 2.8.12)
project(plugin CXX)
add_executable(test test.cc)
em_link_js_library(test "lib.js")
~> emcmake cmake .
configure: cmake . -DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/emscripten/3.1.2/libexec/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/local/bin/node;--experimental-wasm-threads
-- Configuring done
CMake Error: Cannot determine link language for target "test_1_lib_js".
CMake Error: CMake can not determine linker language for target: test_1_lib_js
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
emcmake: error: 'cmake . -DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/emscripten/3.1.2/libexec/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/local/bin/node;--experimental-wasm-threads' failed (returned 1)
```
Hello! I'm trying to create a wasm module for envoy via cpp sdk. To do so, I want to use cmake instead of original advertised Makefile. In order to replicate the [em++ build line](https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/blob/27dbe2e4d3ac2c2b7ecd919d30973486bd522517/Makefile.base_lite#L8) I have created simple `CMakeLists.txt` file with empty `test.cc` and empty `lib.js` files :
```
cmake_minimum_required (VERSION 2.8.12)
project(plugin CXX)
add_executable(test test.cc)
em_link_js_library(test "lib.js")
```
I'm looking for a way to add `--js-library ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.js` into CMake to proceed with the build... But CMake complains: `Cannot determine link language for target "test_1_lib_js".` Even adding
```
set_target_properties(test PROPERTIES LINKER_LANGUAGE CXX)
```
Does not help at all...
Here is the gist example to reproduce the issue: https://gist.github.com/libbkmz/c5090b5a7274de9a18664db3fde8228c
Contributor guide
Assessment
This issue has not been assessed yet.