首先我克隆这个项目: https://github.com/yushi-bot/CGAL_triangulation_demo.
背景: 我正在尝试使用 Emscripten 技术将使用 CGAL 库的 C++ 程序编译为 WebAssembly (wasm) 格式,以在网页上运行它。单独使用CMake时编译成功。但是,当我尝试使用命令 emcmake make ../ 时,编译过程失败了。
cmake ../ (at build folder which make by myself , it is success)
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/lib/x86_64-linux-gnu/cmake/CGAL/CGALConfig.cmake:92 (message):
CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the
default value of CGAL::data_file_path()
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Found GMP: /usr/lib/x86_64-linux-gnu/libgmp.so
-- Found MPFR: /usr/lib/x86_64-linux-gnu/libmpfr.so
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found suitable version "1.74.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Using gcc version 4 or later. Adding -frounding-math
-- Build type:
-- USING CXXFLAGS = ' '
-- USING EXEFLAGS = ' '
CMake Warning at /usr/lib/x86_64-linux-gnu/cmake/CGAL/CGAL_enable_end_of_configuration_hook.cmake:99 (message):
=======================================================================
CGAL performance notice:
The variable CMAKE_BUILD_TYPE is set to "". For performance reasons, you
should set CMAKE_BUILD_TYPE to "Release".
Set CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE to TRUE if you want to disable
this warning.
=======================================================================
Call Stack (most recent call first):
CMakeLists.txt:9223372036854775807 (CGAL_run_at_the_end_of_configuration)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lyciih/github/CGAL_triangulation_demo/build
当我使用这个命令时。
emcmake cmake ../
configure: cmake ../ -DCMAKE_TOOLCHAIN_FILE=/usr/share/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/node;--experimental-wasm-threads
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "FindCGAL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CGAL", but
CMake did not find one.
Could not find a package configuration file provided by "CGAL" with any of
the following names:
CGALConfig.cmake
cgal-config.cmake
Add the installation prefix of "CGAL" to CMAKE_PREFIX_PATH or set
"CGAL_DIR" to a directory containing one of the above files. If "CGAL"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/lyciih/github/CGAL_triangulation_demo/build/CMakeFiles/CMakeOutput.log".
emcmake: error: 'cmake ../ -DCMAKE_TOOLCHAIN_FILE=/usr/share/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/node;--experimental-wasm-threads' failed (returned 1)
请告诉我如何解决它。
感谢您的帮助
该问题与:https://github.com/emscripten-core/emscripten/issues/13310
简而言之:emscripten 的工具链文件限制了包和库的搜索路径,因此无法找到 CGAL。您可以通过在通话期间设置
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH
来覆盖此行为 emcmake cmake ...