Skip to content

Commit

Permalink
Pass -fwasm-exceptions to also the compiler in addition to linker.
Browse files Browse the repository at this point in the history
  • Loading branch information
junhaoliao committed Oct 5, 2024
1 parent 9000016 commit 990fd0c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ project(
CXX
VERSION 0.1.0
)

# Enforce "Unix Makefiles" because "Ninja" does not work with the Emscripten toolchain on CXX_20
# sources.
if(NOT CMAKE_GENERATOR MATCHES "Unix Makefiles")
message(
FATAL_ERROR
"This project is intended to be built with Unix Makefiles on a Unix system."
)
endif()
#
## Enforce "Unix Makefiles" because "Ninja" does not work with the Emscripten toolchain on CXX_20
## sources.
#if(NOT CMAKE_GENERATOR MATCHES "Unix Makefiles")
# message(
# FATAL_ERROR
# "This project is intended to be built with Unix Makefiles on a Unix system."
# )
#endif()

# Enable compile commands by default if the generator supports it.
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
Expand Down Expand Up @@ -72,6 +72,11 @@ message("Boost sources successfully fetched into ${boost_SOURCE_DIR}")

set(CMAKE_EXECUTABLE_SUFFIX ".js" CACHE STRING "Binary type to be generated by Emscripten.")

set(CLP_FFI_JS_ENABLE_EXCEPTION_FLAG
"-fwasm-exceptions"
CACHE STRING
"Exception flag to be enabled on both Emscripten compilers and linkers"
)
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(CLP_FFI_JS_EXTRA_LINKER_FLAGS
-flto
Expand Down Expand Up @@ -106,7 +111,7 @@ set(CLP_FFI_JS_SRC_ZSTD
src/submodules/zstd/lib/decompress/zstd_decompress.c
)

# Define supported environments
# List of supported environments.
set(CLP_FFI_JS_ENVIRONMENTS
"node"
"worker"
Expand All @@ -116,10 +121,11 @@ foreach(env ${CLP_FFI_JS_ENVIRONMENTS})
set(CLP_FFI_JS_BIN_NAME "ClpFfiJs-${env}")
add_executable(${CLP_FFI_JS_BIN_NAME})
target_compile_features(${CLP_FFI_JS_BIN_NAME} PRIVATE cxx_std_20)
target_compile_options(${CLP_FFI_JS_BIN_NAME} PRIVATE ${CLP_FFI_JS_ENABLE_EXCEPTION_FLAG})

set(CLP_FFI_JS_LINKER_FLAGS
${CLP_FFI_JS_ENABLE_EXCEPTION_FLAG}
${CLP_FFI_JS_EXTRA_LINKER_FLAGS}
-fwasm-exceptions
-sALLOW_MEMORY_GROWTH
-sEXPORT_ES6
-sMODULARIZE
Expand Down

0 comments on commit 990fd0c

Please sign in to comment.