File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 9
9
cmake_minimum_required (VERSION 3.8)
10
10
project (xwidgets)
11
11
12
+ if (EMSCRIPTEN)
13
+ set_property (GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE )
14
+ set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1" )
15
+ set (CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1" )
16
+ set (CMAKE_STRIP FALSE )
17
+
18
+ # Define the path to the shared library for use with CppInterOp dynamic loading
19
+ set (XWIDGETS_CPPINTEROP_LIBRARY_PATH "\" /lib/${CMAKE_SHARED_LIBRARY_PREFIX} xwidgets${CMAKE_SHARED_LIBRARY_SUFFIX} \" " )
20
+ message (STATUS "XWIDGETS_CPPINTEROP_LIBRARY_PATH = ${XWIDGETS_CPPINTEROP_LIBRARY_PATH} " )
21
+ endif ()
22
+
12
23
set (XWIDGETS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /include )
13
24
set (XWIDGETS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /src)
14
25
@@ -157,6 +168,9 @@ macro(xwidgets_create_target target_name linkage output_name)
157
168
)
158
169
159
170
target_link_libraries (${target_name} PUBLIC ${XEUS_TARGET_NAME} xproperty)
171
+ if (EMSCRIPTEN)
172
+ set_target_properties (${target_name} PROPERTIES NO_SONAME 1)
173
+ endif ()
160
174
161
175
set_target_properties (
162
176
${target_name}
@@ -182,7 +196,11 @@ macro(xwidgets_create_target target_name linkage output_name)
182
196
OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
183
197
OR CMAKE_CXX_COMPILER_ID MATCHES "Intel"
184
198
)
185
- target_compile_options (${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder)
199
+ if (EMSCRIPTEN)
200
+ target_compile_options (${target_name} PRIVATE -fPIC)
201
+ else ()
202
+ target_compile_options (${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder)
203
+ endif ()
186
204
187
205
message (STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS} " )
188
206
endif ()
Original file line number Diff line number Diff line change 106
106
#include " xwidgets_config_cling.hpp"
107
107
#endif
108
108
109
+ #if defined(__CLANG_REPL__) && defined(__EMSCRIPTEN__)
110
+ #include " xwidgets_config_cling.hpp"
111
+ #endif
112
+
109
113
#endif
Original file line number Diff line number Diff line change 9
9
#ifndef XWIDGETS_CONFIG_CLING_HPP
10
10
#define XWIDGETS_CONFIG_CLING_HPP
11
11
12
+ #ifdef __CLING__
13
+
12
14
#pragma cling add_library_path(@XWIDGETS_INSTALL_LIBRARY_DIR@)
13
15
#pragma cling load("libxwidgets")
14
16
17
+ #elif defined(__EMSCRIPTEN__) && defined(__CLANG_REPL__)
18
+
19
+ #include <clang/Interpreter/CppInterOp.h>
20
+ static bool _xwidgets_loaded = []() {
21
+ Cpp::LoadLibrary(@XWIDGETS_CPPINTEROP_LIBRARY_PATH@, false);
22
+ return true;
23
+ }();
24
+
15
25
#endif
26
+
27
+ #endif // XWIDGETS_CONFIG_CLING_HPP
You can’t perform that action at this time.
0 commit comments