Setting emcc options via emcmake?

1,125 views
Skip to first unread message

Steven Johnson

unread,
Oct 27, 2021, 7:59:31 PM10/27/21
to emscripte...@googlegroups.com
If I am using emcmake to build an existing CMake-based executable, what's the right / best way to set emcc options? (e.g. -s ASSERTIONS=1 -s ENVIRONMENT=node)?

Random googling hasn't found a definitive answer. Some hits suggest that I can use target_compile_options() and/or target_link_opions() in my CMake build files to set these, but it would be nice if I could (also) just specify them on the command line (for cases where the CMake files aren't yet modified to be smart).


Shlomi Fish

unread,
Oct 28, 2021, 12:56:51 AM10/28/21
to 'Steven Johnson' via emscripten-discuss
Hi Steven!

On Wed, 27 Oct 2021 16:59:17 -0700
"'Steven Johnson' via emscripten-discuss" <emscripte...@googlegroups.com>
wrote:
Perhaps try using these:
https://emscripten.org/docs/tools_reference/emcc.html#environment-variables .
(Untested!)

--

Shlomi Fish https://www.shlomifish.org/
https://youtu.be/GoEn1YfYTBM - Tiffany Alvord - “Fall Together”

God created the world in 6 days and rested on the 7th. Chuck Norris created
the world in one day, and has been incrementally destroying it every day since,
without rest.

Please reply to list if it's a mailing list post - https://shlom.in/reply .

Sam Clegg

unread,
Oct 28, 2021, 7:44:48 PM10/28/21
to emscripte...@googlegroups.com
On Wed, Oct 27, 2021 at 4:59 PM 'Steven Johnson' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
If I am using emcmake to build an existing CMake-based executable, what's the right / best way to set emcc options? (e.g. -s ASSERTIONS=1 -s ENVIRONMENT=node)?

Random googling hasn't found a definitive answer. Some hits suggest that I can use target_compile_options() and/or target_link_opions() in my CMake build files to set these, but it would be nice if I could (also) just specify them on the command line (for cases where the CMake files aren't yet modified to be smart).

We don't support anything special here, so the answer is the same as if you had asked "how to I pass extra compile and/or link flags to a cmake project".  

I think the answer is here: https://stackoverflow.com/questions/44284275/passing-compiler-options-cmake.  Do -DCMAKE_C_FLAGS=... and -DCMAKE_CXX_FLAGS=... work for you?

 


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAM%3DdnvcfdQqqYP1xNznuLZK19kjaq2sPfhY%3DQTYxpWtgZhfgdw%40mail.gmail.com.

Floh

unread,
Nov 1, 2021, 9:34:45 AM11/1/21
to emscripten-discuss
You can handle emscripten specific options inside an if-block which check that CMAKE_SYSTEM_NAME is "Emscripten". For example see here at the start and towards the end of the CMakeLists.txt file:

Reply all
Reply to author
Forward
0 new messages