The "easy way" is to use the emcmake wrapper that comes with the Emscripten SDK, AFAIK what this does is invoke CMake with an Emscripten specific toolchain file (which lives here:
https://github.com/emscripten-core/emscripten/blob/main/cmake/Modules/Platform/Emscripten.cmake).
I have an example for this here (see the emscripten build instructions in the readme, and checkout the CMakeLists.txt file which has some emscripten specific settings):
The next option is to skip the emcmake wrapper and use the SDK's toolchain file, or your own variation of this toolchain file. The starting point is to run cmake giving it emscripten's toolchain file:
cmake -DCMAKE_TOOLCHAIN_FILE=[path to emsdk toolchain file] ..
AFAIK including a toolchain file in the CMakeLists.txt file based on a CMake option suffers from a chicken-egg situation, it's more robust to set the toolchain file as part of the command line invocation.
This is basically a "cmake crosscompiling scenario" with a custom toolchain file (as opposed to cmake's builtin cross compiling targets). CMake's documentation for this is here:
Cheers!