在简单的(?)项目中使用emscripten和CMake

时间:2015-07-03 21:30:08

标签: c++ cmake cgal emscripten

所以我有一个相当简单的C ++程序,使用CGAL并使用CMake构建。我可以在没有emscripten的情况下成功构建并运行它:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Unix Makefiles" .
[output looks good]
make
[command works]

一切都很好,我可以运行输出,然而当我尝试使用Emscripten时(这对我过去有用):

cmake -DCMAKE_TOOLCHAIN_FILE=/home/brenden/emsdk_portable/emscripten/master/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Unix Makefiles" .
[output looks good]
make
main.cpp:2:10: fatal error: 'CGAL/Triangulation_3.h' file not found
#include <CGAL/Triangulation_3.h>
         ^
1 error generated.
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting
make[2]: *** [CMakeFiles/cgal_test.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/cgal_test.dir/all] Error 2
make: *** [all] Error 2

这显然不起作用。

我的CMakeLists.txt看起来像这样:

cmake_minimum_required(VERSION 2.8)
project(cgal_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(cgal_test ${SOURCE_FILES})
target_link_libraries(cgal_test CGAL gmp)

有什么想法吗?所有的CGAL库和标题都在usr / local /中,所以我对发生的事情感到很茫然。

1 个答案:

答案 0 :(得分:3)

嗯,所以事实证明你不能只是在一个库中链接,emscripten docs指出你“......将库构建到bitcode然后将库和主程序bitcode一起编译成JavaScript 。“

这听起来很傻和痛苦,但我猜这就是答案。