Skip to content

Commit 5e6c741

Browse files
authored
[emcmake] Insert toolchain/emulator arg after user args (emscripten-core#15265)
This allows user specified command line arg to overwrite whatever is specified in the toolchain file, can be useful to overwrite variables like CMAKE_SYSTEM_PROCESSOR, which is used by projects to detect if system is ARM. This way we can exercise both Emscripten's SSE headers and NEON headers.
1 parent d946a8f commit 5e6c741

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

emcmake.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def run():
2929
def has_substr(args, substr):
3030
return any(substr in s for s in args)
3131

32-
# Append the Emscripten toolchain file if the user didn't specify one.
32+
# Insert arg for the Emscripten toolchain file if the user didn't specify one.
33+
# User specified arguments come afterwards so they can overwrite variables defined in toolchain file.
3334
if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE'):
34-
args.append('-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root('cmake/Modules/Platform/Emscripten.cmake'))
35+
args.insert(1, '-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root('cmake/Modules/Platform/Emscripten.cmake'))
3536

3637
if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'):
3738
node_js = config.NODE_JS[0]
38-
args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}')
39+
args.insert(1, f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}')
3940

4041
# On Windows specify MinGW Makefiles or ninja if we have them and no other
4142
# toolchain was specified, to keep CMake from pulling in a native Visual

0 commit comments

Comments
 (0)