|
| 1 | +diff --git a/symengine/CMakeLists.txt b/symengine/CMakeLists.txt |
| 2 | +index 2ae82f97..2ecc489f 100644 |
| 3 | +--- a/symengine/CMakeLists.txt |
| 4 | ++++ b/symengine/CMakeLists.txt |
| 5 | +@@ -1,3 +1,8 @@ |
| 6 | ++set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) |
| 7 | ++set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1") |
| 8 | ++set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1") |
| 9 | ++set(CMAKE_STRIP FALSE) |
| 10 | ++ |
| 11 | + if (WITH_SYMENGINE_TEUCHOS) |
| 12 | + add_subdirectory(utilities/teuchos) |
| 13 | + # Include Teuchos headers: |
| 14 | +@@ -275,6 +280,9 @@ include(GNUInstallDirs) |
| 15 | + # Configure SymEngine using our CMake options: |
| 16 | + set(SYMENGINE_CLING_LIBRARY_DIR "\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\"") |
| 17 | + |
| 18 | ++set(SYMENGINE_CPPINTEROP_LIBRARY_PATH "\"/lib/${CMAKE_SHARED_LIBRARY_PREFIX}symengine${CMAKE_SHARED_LIBRARY_SUFFIX}\"") |
| 19 | ++message(STATUS "SYMENGINE_CPPINTEROP_LIBRARY_PATH = ${SYMENGINE_CPPINTEROP_LIBRARY_PATH}") |
| 20 | ++ |
| 21 | + configure_file(symengine_config.h.in symengine_config.h) |
| 22 | + configure_file(symengine_config_cling.h.in symengine_config_cling.h) |
| 23 | + |
| 24 | +@@ -283,7 +291,9 @@ include_directories(BEFORE ${symengine_BINARY_DIR}) |
| 25 | + # Include the source directory |
| 26 | + include_directories(BEFORE ${symengine_SOURCE_DIR}) |
| 27 | + |
| 28 | +-add_library(symengine ${SRC}) |
| 29 | ++add_library(symengine SHARED |
| 30 | ++${SRC} |
| 31 | ++) |
| 32 | + |
| 33 | + include(GenerateExportHeader) |
| 34 | + generate_export_header(symengine) |
| 35 | +@@ -321,6 +331,7 @@ if (WITH_SYMENGINE_TEUCHOS) |
| 36 | + target_link_libraries(symengine teuchos) |
| 37 | + endif() |
| 38 | + target_link_libraries(symengine ${LIBS}) |
| 39 | ++set_target_properties(symengine PROPERTIES NO_SONAME 1) |
| 40 | + |
| 41 | + if (WITH_LLVM AND NOT SYMENGINE_LLVM_LINK_DOWNSTREAM AND NOT WITH_SYMENGINE_TEUCHOS) |
| 42 | + if (${EXCLUDE_LIBS}) |
| 43 | +diff --git a/symengine/expression.h b/symengine/expression.h |
| 44 | +index 5d0c63e7..c6427bc4 100644 |
| 45 | +--- a/symengine/expression.h |
| 46 | ++++ b/symengine/expression.h |
| 47 | +@@ -341,11 +341,11 @@ struct print_coefficient_impl<U, typename std::enable_if<std::is_same< |
| 48 | + } // namespace piranha |
| 49 | + #endif // HAVE_SYMENGINE_PIRANHA |
| 50 | + |
| 51 | +-// Utility functions for xeus-cling |
| 52 | ++// Utility functions for xeus-cpp |
| 53 | + namespace SymEngine |
| 54 | + { |
| 55 | + |
| 56 | +-#ifdef __CLING__ |
| 57 | ++#if defined(__CLANG_REPL__) |
| 58 | + // clang-format off |
| 59 | + #if defined(__has_include) && __has_include(<nlohmann/json.hpp>) |
| 60 | + // clang-format on |
| 61 | +diff --git a/symengine/symengine_config.h.in b/symengine/symengine_config.h.in |
| 62 | +index f90b9974..6394dce6 100644 |
| 63 | +--- a/symengine/symengine_config.h.in |
| 64 | ++++ b/symengine/symengine_config.h.in |
| 65 | +@@ -93,7 +93,7 @@ |
| 66 | + |
| 67 | + #include <symengine/symengine_export.h> |
| 68 | + |
| 69 | +-#ifdef __CLING__ |
| 70 | ++#if defined(__CLANG_REPL__) && defined(__EMSCRIPTEN__) |
| 71 | + #include "symengine/symengine_config_cling.h" |
| 72 | + #endif |
| 73 | + |
| 74 | +diff --git a/symengine/symengine_config_cling.h.in b/symengine/symengine_config_cling.h.in |
| 75 | +index bf99d723..91ea1042 100644 |
| 76 | +--- a/symengine/symengine_config_cling.h.in |
| 77 | ++++ b/symengine/symengine_config_cling.h.in |
| 78 | +@@ -1,7 +1,10 @@ |
| 79 | + #ifndef SYMENGINE_CONFIG_CLING_HPP |
| 80 | + #define SYMENGINE_CONFIG_CLING_HPP |
| 81 | + |
| 82 | +-#pragma cling add_library_path(@SYMENGINE_CLING_LIBRARY_DIR@) |
| 83 | +-#pragma cling load("@CMAKE_SHARED_LIBRARY_PREFIX@symengine") |
| 84 | ++#include "clang/Interpreter/CppInterOp.h" |
| 85 | ++static bool _symengine_loaded = []() { |
| 86 | ++ Cpp::LoadLibrary(@SYMENGINE_CPPINTEROP_LIBRARY_PATH@); |
| 87 | ++ return true; |
| 88 | ++}(); |
| 89 | + |
| 90 | + #endif |
0 commit comments