Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If at all, how is it possible to detect that CMakeLists.txt is run by 'emcmake cmake' instead of just 'cmake'?

I have a project that shall be configured/built differently when either using cmake or emcmake cmake (followed by make or emmake make respectively). For example, I don't need to build a test executable if it is run by emcmake cmake as the result will be WebAssembly.

So, is there any variable available when run by emcmake cmake, that I could query? Are there other approaches?

like image 631
stackprotector Avatar asked Nov 27 '25 10:11

stackprotector


1 Answers

You can detect if emcmake cmake or emconfigure cmake are used with the EMSCRIPTEN variable:

if(EMSCRIPTEN)
    message("Using emscripten!")
else()
    message("Not using emscripten!")
endif()
like image 127
cajomar Avatar answered Dec 01 '25 05:12

cajomar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!