@@ -51,15 +51,16 @@ message(STATUS "Building xeus-cpp v${${PROJECT_NAME}_VERSION}")
5151# =============
5252
5353option (XEUS_CPP_BUILD_STATIC "Build xeus-cpp static library" ON )
54- OPTION (XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON )
55- OPTION (XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON )
54+ option (XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON )
55+ option (XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON )
5656
57- OPTION (XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON )
58- OPTION (XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON )
57+ option (XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON )
58+ option (XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON )
59+ option (XEUS_CPP_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF )
5960
6061# Test options
61- OPTION (XEUS_CPP_BUILD_TESTS "xeus-cpp test suite" ON )
62- OPTION (XEUS_CPP_ENABLE_CODE_COVERAGE "xeus-cpp test suite" OFF )
62+ option (XEUS_CPP_BUILD_TESTS "xeus-cpp test suite" ON )
63+ option (XEUS_CPP_ENABLE_CODE_COVERAGE "xeus-cpp test suite" OFF )
6364if (XEUS_CPP_ENABLE_CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
6465 string (TOUPPER "${CMAKE_BUILD_TYPE} " uppercase_CMAKE_BUILD_TYPE)
6566 if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
@@ -76,20 +77,22 @@ endif()
7677if (EMSCRIPTEN)
7778 add_compile_definitions (XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
7879 message ("Build with emscripten" )
79- SET (XEUS_CPP_BUILD_STATIC ON )
80- SET (XEUS_CPP_BUILD_SHARED OFF )
81- SET (XEUS_CPP_BUILD_EXECUTABLE OFF )
82- SET (XEUS_CPP_USE_SHARED_XEUS OFF )
83- SET (XEUS_CPP_USE_SHARED_XEUS_CPP OFF )
84- SET (XEUS_CPP_BUILD_TESTS OFF )
80+ set (XEUS_CPP_BUILD_STATIC ON )
81+ set (XEUS_CPP_BUILD_SHARED OFF )
82+ set (XEUS_CPP_BUILD_EXECUTABLE OFF )
83+ set (XEUS_CPP_USE_SHARED_XEUS OFF )
84+ set (XEUS_CPP_USE_SHARED_XEUS_CPP OFF )
85+ set (XEUS_CPP_BUILD_TESTS OFF )
86+ # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0)
87+ set (EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \" EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\" " )
8588endif ()
8689
87-
8890# Dependencies
8991# ============
9092
9193set (xeus_REQUIRED_VERSION 5.0.0)
9294set (xeus_zmq_REQUIRED_VERSION 3.0.0)
95+ set (CppInterOp_REQUIRED_VERSION 1.3.0)
9396
9497if (NOT TARGET xeus AND NOT TARGET xeus-static )
9598 find_package (xeus ${xeus_REQUIRED_VERSION} REQUIRED)
@@ -98,31 +101,6 @@ if (NOT TARGET xeus AND NOT TARGET xeus-static)
98101 endif ()
99102endif ()
100103
101- set (CppInterOp_REQUIRED_VERSION 1.3.0)
102-
103- # Flags
104- # =====
105- include (CheckCXXCompilerFlag)
106-
107- if (MSVC )
108- add_compile_options (/wd4251 /wd4141)
109- add_compile_options (/wd4018 /wd4267 /wd4715 /wd4146 /wd4129)
110- add_compile_options (/EHsc)
111- else ()
112- add_compile_options (-fexceptions)
113- endif ()
114-
115- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
116- if (NOT EMSCRIPTEN)
117- add_compile_options (-Wunused-parameter -Wextra -Wreorder)
118- endif ()
119- endif ()
120-
121- if (EMSCRIPTEN)
122- # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0)
123- set (EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \" EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\" " )
124- endif ()
125-
126104find_package (CppInterOp ${CppInterOp_REQUIRED_VERSION} REQUIRED)
127105if (CppInterOp_FOUND)
128106 message (STATUS "Found CppInterOp: config=${CPPINTEROP_CONFIG} dir=${CPPINTEROP_DIR} (found version=${CPPINTEROP_VERSION} compatible with Clang ${CPPINTEROP_LLVM_VERSION_MAJOR} .x)" )
@@ -234,13 +212,20 @@ macro(xeus_cpp_set_common_options target_name)
234212 if (MSVC )
235213 target_compile_options (${target_name} PUBLIC /wd4251 /wd4141)
236214 target_compile_options (${target_name} PUBLIC /wd4018 /wd4267 /wd4715 /wd4146 /wd4129)
215+ target_compile_options (${target_name} PUBLIC /EHsc)
216+ else ()
217+ target_compile_options (${target_name} PUBLIC -fexceptions)
237218 endif ()
238219
239220 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
240221 CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
241222 CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
242223
243- target_compile_options (${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder)
224+ if (EMSCRIPTEN)
225+ target_compile_options (${target_name} PRIVATE -fPIC)
226+ else ()
227+ target_compile_options (${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder)
228+ endif ()
244229
245230 # C++17 flag
246231 CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP_17_FLAG)
@@ -347,7 +332,6 @@ macro(xeus_cpp_create_target target_name linkage output_name)
347332 # Curl initialised specifically for xassist
348333 target_link_libraries (${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse curl)
349334 else ()
350- # TODO : Add curl support for emscripten
351335 target_link_libraries (${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse)
352336 endif ()
353337
@@ -505,9 +489,6 @@ if (XEUS_CPP_BUILD_SHARED)
505489endif ()
506490
507491if (EMSCRIPTEN)
508- install (TARGETS xcpp
509- ARCHIVE DESTINATION ${XEUS_CPP_CMAKECONFIG_INSTALL_DIR} )
510-
511492 install (FILES
512493 "$<TARGET_FILE_DIR:xcpp>/xcpp.js"
513494 "$<TARGET_FILE_DIR:xcpp>/xcpp.wasm"
0 commit comments