diff --git a/Modules/Platform/Emscripten-Clang.cmake b/Modules/Platform/Emscripten-Clang.cmake index 90de19a290..9081ea4258 100644 --- a/Modules/Platform/Emscripten-Clang.cmake +++ b/Modules/Platform/Emscripten-Clang.cmake @@ -15,9 +15,10 @@ macro(__emscripten_clang lang) get_property(_TARGET_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) if(_TARGET_SUPPORTS_SHARED_LIBS) # Emscripten requires '-sMAIN_MODULE' and '-sSIDE_MODULE' to distinguish - # linking executables from linking shared libraries. + # linking executables from linking shared libraries. Place them early + # so that project-specified link flags can override them. set(CMAKE_${lang}_LINK_EXECUTABLE - " -o -sMAIN_MODULE") + " -sMAIN_MODULE -o ") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-sSIDE_MODULE") else() # Emscripten provides a combined toolchain file and platform module that