emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.96k stars 676 forks source link

emcmake: no compatible cmake generator found #1311

Open vault-thirteen opened 8 months ago

vault-thirteen commented 8 months ago

https://emscripten.org/docs/compiling/Building-Projects.html If I ignore the first command from the manual and use emcmake, I see this. emcmake cmake .

emcmake: no compatible cmake generator found; Please install ninja or mingw32-make, or specify a generator explicitly using -G

It is important to state that when I use CMake directly without Emscripten, all the tools are found.

If I use cmake without emcmake, it works fine. cmake .

cmake .
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.38.33130.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
Product Name: Argon2 library
Project Version: 0.1.0.0.
Product Version: 0,1,0,0.
File Version: 0,1,0,0.
Source Files: src/argon2.c;src/bench.c;src/core.c;src/encoding.c;src/thread.c;src/blake2/blake2b.c;src/ref.c.
Public Header Files: include/argon2.h.
AVX: no.
Version.rc: no.
-- Configuring done (1.6s)
-- Generating done (0.0s)
-- Build files have been written to: D:/Temp/1/argon2

Source code was taken from here: https://github.com/vault-thirteen/argon2

Why is the emcmake not seeing my compilers ? How do I tell it to see them ? Where is the manual how to use it ? Neither -h nor /? arguments show any help information about this emcmake tool. Simple execution without arguments and --help also do not provide any help.

Googling also is not fruitful. https://www.google.com/search?q=emcmake+usage

I have also found this issue which states that we need some user guide about how to use this tool. https://github.com/emscripten-core/emscripten/issues/2655

Thank you.

sbc100 commented 8 months ago

The visual studio CMake generator cannot be used with emscripten. You need to use either ninja or mingw32-make. This is because emscripten is a cross compiler and the visual studio generator doesn't support cross compilation.. only compilation using cl.exe.

sbc100 commented 8 months ago

Hopefully the error message is fairly clear on what you need to do: "Please install ninja or mingw32-make, or specify a generator explicitly using -G"

vault-thirteen commented 8 months ago

Where can I read the help for this -G argument of the emcmake tool ? Where is the user manual for the emcmake tool ?

sbc100 commented 8 months ago

-G is a cmake flag. It allows you to specify a generator: https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-G

However, if you install ninja then you don't need to explictly specify -G since emcmake will inject it for you. I would recommend just installing ninja from here : https://ninja-build.org/

vault-thirteen commented 8 months ago

Thank you. Is it mentioned in the manual ? I thought it was an argument of emcmake tool.

sbc100 commented 8 months ago

emcmake is a wrapper around cmake so all arguments you pass to emcmake will get passed on to cmake.

I don't think we specifically mention generator support, but then again we have little documentation on emcmake. What we do have is here: https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system. If you would like to contribute more that would be most welsome.