Using emscripten with CMake in a simple (?) Project

So, I have a fairly simple C ++ program that uses CGAL and is built with CMake. I can build and run it without emscripten:

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

      

Everything is fine and I can run the output however when I try to use Emscripten like this (which has worked for me in the past):

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

      

This obviously doesn't work.

My CMakeLists.txt looks like this:

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)

      

Any ideas? All CGAL libraries and headers are in usr / local /, so I kind of don't understand what's going on.

+3


source to share


1 answer


Hmmm, so it turns out that you can't just link in a library, the emscripten docs tell you that you "... create libraries for bitcode and then compile the library and main bitcode along with JavaScript".



It sounds silly and painful, but I think the answer is.

+2


source







All Articles