@@ -51,15 +51,16 @@ message(STATUS "Building xeus-cpp v${${PROJECT_NAME}_VERSION}")
51
51
# =============
52
52
53
53
option (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 )
56
56
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 )
59
60
60
61
# 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 )
63
64
if (XEUS_CPP_ENABLE_CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
64
65
string (TOUPPER "${CMAKE_BUILD_TYPE} " uppercase_CMAKE_BUILD_TYPE)
65
66
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
@@ -76,20 +77,22 @@ endif()
76
77
if (EMSCRIPTEN)
77
78
add_compile_definitions (XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
78
79
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']\" " )
85
88
endif ()
86
89
87
-
88
90
# Dependencies
89
91
# ============
90
92
91
93
set (xeus_REQUIRED_VERSION 5.0.0)
92
94
set (xeus_zmq_REQUIRED_VERSION 3.0.0)
95
+ set (CppInterOp_REQUIRED_VERSION 1.3.0)
93
96
94
97
if (NOT TARGET xeus AND NOT TARGET xeus-static )
95
98
find_package (xeus ${xeus_REQUIRED_VERSION} REQUIRED)
@@ -98,31 +101,6 @@ if (NOT TARGET xeus AND NOT TARGET xeus-static)
98
101
endif ()
99
102
endif ()
100
103
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
-
126
104
find_package (CppInterOp ${CppInterOp_REQUIRED_VERSION} REQUIRED)
127
105
if (CppInterOp_FOUND)
128
106
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)
234
212
if (MSVC )
235
213
target_compile_options (${target_name} PUBLIC /wd4251 /wd4141)
236
214
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)
237
218
endif ()
238
219
239
220
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
240
221
CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
241
222
CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
242
223
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 ()
244
229
245
230
# C++17 flag
246
231
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)
347
332
# Curl initialised specifically for xassist
348
333
target_link_libraries (${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse curl)
349
334
else ()
350
- # TODO : Add curl support for emscripten
351
335
target_link_libraries (${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse)
352
336
endif ()
353
337
@@ -505,9 +489,6 @@ if (XEUS_CPP_BUILD_SHARED)
505
489
endif ()
506
490
507
491
if (EMSCRIPTEN)
508
- install (TARGETS xcpp
509
- ARCHIVE DESTINATION ${XEUS_CPP_CMAKECONFIG_INSTALL_DIR} )
510
-
511
492
install (FILES
512
493
"$<TARGET_FILE_DIR:xcpp>/xcpp.js"
513
494
"$<TARGET_FILE_DIR:xcpp>/xcpp.wasm"
0 commit comments