I'm currently trying to convert CGAL to Javascript using the awesome LLVM-> Javascript project called Emscripten. I just do it only with the main component (and not with ImageIO or Qt)
I managed to do this with two of its dependencies (GMP and MPFR). To my great surprise, I was able to compile C test classes in Javascript for both of them (against the generated LLVM libraries in the form of bit code), the output of which is executed in nodejs, exactly matches my own result.
All other dependencies have only headers (Eigen, Boost), except for one - libboost-thread. Now, obviously, JS is single-threaded, so we hope you can discard this CGAL code. Fortunately, the CGAL_HAS_NO_THREADS macro, which I defined this way:
add_definitions( -DCGAL_HAS_NO_THREADS=1 )
And that seems to be passed to the command line as the -D option
However, when I try to compile with clang (setup by running cmake with the Emscripten tool, which installs clang, etc.), I get a whole bunch of errors that I donβt get when compiling with gcc, which seem twofold:
1) Firstly, these are things like:
#if defined (__GLIBC__) # include <endian.h> # if (__BYTE_ORDER == __LITTLE_ENDIAN) # define CGAL_LITTLE_ENDIAN # elif (__BYTE_ORDER == __BIG_ENDIAN) # define CGAL_BIG_ENDIAN # else # error Unknown endianness # endif #elif defined(__sparc) || defined(__sparc__) \ || defined(_POWER) || defined(__powerpc__) \ || defined(__ppc__) || defined(__hppa) \ || defined(_MIPSEB) || defined(_POWER) \ || defined(__s390__) # define CGAL_BIG_ENDIAN #elif defined(__i386__) || defined(__alpha__) \ || defined(__x86_64) || defined(__x86_64__) \ || defined(__ia64) || defined(__ia64__) \ || defined(_M_IX86) || defined(_M_IA64) \ || defined(_M_ALPHA) || defined(_WIN64) # define CGAL_LITTLE_ENDIAN #else # error Unknown endianness #endif
This gives me the error "Unknown error". I assume the clang compiler does not define a GLIBC macro?
Another way:
In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/src/CGAL/all_files.cpp:1: In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/src/CGAL/Random.cpp:25: In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/include/CGAL/Random.h:30: In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/include/CGAL/basic.h:44: In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/include/CGAL/number_type_basic.h:77: In file included from /home/marcosscriven/sources/openscadjs/build/CGAL-4.1/include/CGAL/FPU.h:60: In file included from /usr/lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7/fenv.h:33: In file included from /usr/lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7/i686-linux-gnu/bits/c++config.h:414: In file included from /usr/lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7/i686-linux-gnu/bits/os_defines.h:40: /home/marcosscriven/sources/includes/features.h:324:10: fatal error: 'bits/predefs.h' file not found #include <bits/predefs.h>
It seems that in order to find libs, you can use clag using a different patch (or a set of paths or an order of paths).
Now both things, obviously, I can hack in parts - but I guess this is not the βrightβ way.
The problem I am facing is knowing which macros are defined when running clang (or even gcc)? Am I not sure that all attachments to the root directory / usr / include /?
I know that some of them are GNUC, and that it is somehow different from std libc and libcxx libs? But not all of them?
Any help is greatly appreciated.
Marcos