From 05a54749cb3dede03d56d6c6e9deb643c9b05ad6 Mon Sep 17 00:00:00 2001 From: Bui Quang Huy <34532913+LazyYuuki@users.noreply.github.com> Date: Tue, 15 Apr 2025 22:40:37 +0800 Subject: [PATCH] Allow to be built to WebAssembly using emscripten - Add emscripten option to use -lm instead of LibM library --- src/CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1407080..b4dea44 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,9 +49,14 @@ target_include_directories(ccd PUBLIC $) if(NOT WIN32) - find_library(LIBM_LIBRARY NAMES m) - if(NOT LIBM_LIBRARY) - message(FATAL_ERROR "Could NOT find required library LibM") + if (EMSCRIPTEN) + set(LIBM_LIBRARY "-lm") + message("Subtitute LibM with emscripten -lm") + else() + find_library(LIBM_LIBRARY NAMES m) + if(NOT LIBM_LIBRARY) + message(FATAL_ERROR "Could NOT find required library LibM") + endif() endif() target_link_libraries(ccd "${LIBM_LIBRARY}") if(BUILD_SHARED_LIBS)