|
|
@@ -6,24 +6,16 @@ include_guard()
|
|
|
macro(__emscripten_clang lang)
|
|
|
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
|
|
|
|
|
|
+ # FIXME(#27240): We do not add -sMAIN_MODULE to CMAKE_${lang}_LINK_EXECUTABLE
|
|
|
+ # because it is not always needed, and can break things if added unnecessarily.
|
|
|
+ # We also do not add -sMAIN_MODULE to CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS
|
|
|
+ # to preserve legacy behavior in which projects added it as needed.
|
|
|
+ # In the future we may add both flags with suitable controls.
|
|
|
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "")
|
|
|
+
|
|
|
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
|
|
|
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
|
|
|
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
|
|
|
set(CMAKE_${lang}_COMPILE_OBJECT
|
|
|
"<CMAKE_${lang}_COMPILER> -c <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -fPIC")
|
|
|
-
|
|
|
- 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. Place them early
|
|
|
- # so that project-specified link flags can override them.
|
|
|
- set(CMAKE_${lang}_LINK_EXECUTABLE
|
|
|
- "<CMAKE_${lang}_COMPILER> -sMAIN_MODULE <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
|
|
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-sSIDE_MODULE")
|
|
|
- else()
|
|
|
- # Emscripten provides a combined toolchain file and platform module that
|
|
|
- # predates CMake upstream support. It turns off support for shared libraries.
|
|
|
- # Avoid linking with '-sMAIN_MODULE' or '-sSIDE_MODULE' in that case.
|
|
|
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "")
|
|
|
- endif()
|
|
|
endmacro()
|