Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=strict") # to avoid FP differences in CI
endif()

# support for Emscripten/WASM
set(patch_random123_wasm)
if(EMSCRIPTEN)
message(NOTICE "Detected Emscripten toolchain")
set(patch_random123_wasm git apply ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/random123_wasm.patch)
set(CMAKE_TOOLCHAIN_FILE $ENV{EMSDK_HOME}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -167,6 +176,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RELEASE")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(APPEND MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS
"-Wno-stringop-overread;"
"-Wno-c2y-extensions;" # use c2y extensions, as they have been supported for a long time
)
endif()
endif()
Expand Down
4 changes: 3 additions & 1 deletion cpp/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ message(STATUS "Downloading Random123 library")
include(FetchContent)
FetchContent_Declare(Random123
GIT_REPOSITORY https://github.com/DEShawResearch/random123
GIT_TAG ${MEMILIO_RANDOM123_VERSION})
GIT_TAG ${MEMILIO_RANDOM123_VERSION}
PATCH_COMMAND ${patch_random123_wasm}
UPDATE_DISCONNECTED 1)
FetchContent_MakeAvailable(Random123)

add_library(Random123 INTERFACE)
Expand Down
13 changes: 13 additions & 0 deletions cpp/thirdparty/random123_wasm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/Random123/features/gccfeatures.h b/include/Random123/features/gccfeatures.h
index 51c46aa..9315b8b 100644
--- a/include/Random123/features/gccfeatures.h
+++ b/include/Random123/features/gccfeatures.h
@@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#define R123_GNUC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)

-#if !defined(__x86_64__) && !defined(__i386__) && !defined(__powerpc__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__s390x__)
+#if !defined(__x86_64__) && !defined(__i386__) && !defined(__powerpc__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__s390x__) && !defined(__wasm__)
# error "This code has only been tested on x86, powerpc and a few arm platforms."
#include <including_a_nonexistent_file_will_stop_some_compilers_from_continuing_with_a_hopeless_task>
{ /* maybe an unbalanced brace will terminate the compilation */
3 changes: 2 additions & 1 deletion pycode/memilio-simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ endif()
set(CMAKE_CXX_STANDARD "20")
set(CMAKE_CXX_STANDARD_REQUIRED "20")

option(MEMILIO_BUILD_SHARED_LIBS "Build memilio as a shared library." ON)
option(MEMILIO_USE_BUNDLED_PYBIND11 "Use pybind11 bundled with this library." ON)
mark_as_advanced(MEMILIO_USE_BUNDLED_PYBIND11)
mark_as_advanced(MEMILIO_BUILD_SHARED_LIBS MEMILIO_USE_BUNDLED_PYBIND11)

include(GNUInstallDirs) # set to gnu folders. No cache variable so this is not global

Expand Down
2 changes: 1 addition & 1 deletion pycode/memilio-simulation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ build-backend = "scikit_build_core.build"

[tool.scikit-build]
cmake.version = ">=3.13"
cmake.args = ["-DMEMILIO_BUILD_SHARED_LIBS:BOOL=ON"]
cmake.args = []
wheel.packages = ["memilio"]
wheel.install-dir = "memilio/simulation"
sdist.cmake = true
Expand Down
Loading