确定clang和cmake定义的宏的最佳方法

Mar*_*ven 5 c++ ide llvm clang emscripten

我目前正在尝试将CGAL转换为Javascript,使用一个名为Emscripten的惊人的LLVM-> Javascript项目.我只是用核心组件做这个(不是ImageIO或Qt的东西)

我已经设法用它的两个依赖项(GMP和MPFR)来做到这一点.出乎我的意料,我能够编译C测试类的Javascript两个那些(针对位码形式产生LLVM库),其中在运行的NodeJS精确匹配本地结果输出.

除了one-libboost-thread之外,所有其他依赖项都是header-only(Eigen,Boost).现在,显然JS是单线程的,因此希望能够从CGAL代码中删除它.幸运的是CGAL_HAS_NO_THREADS宏,我已经定义了它:

add_definitions( -DCGAL_HAS_NO_THREADS=1 )
Run Code Online (Sandbox Code Playgroud)

这似乎确实作为-D选项传递给命令行

但是,当我尝试使用clang进行编译时(通过设置clang等的Emscripten工具运行cmake进行设置),我得到了一大堆在使用gcc编译时没有得到的错误,这似乎是双重的:

1)首先是:

    #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
Run Code Online (Sandbox Code Playgroud)

这给了我一个'未知的Endianness'错误.我假设是由于clang编译器没有定义GLIBC宏?

另一个是这样的事情:

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>
Run Code Online (Sandbox Code Playgroud)

这似乎是使用不同的补丁(或路径集或路径顺序)来查找libs.

现在两件事显然我可以一点一点地破解 - 但我猜这不是'正确'的方式.

我遇到的麻烦是知道在运行clang(甚至是gcc)时定义了哪些宏?我也不确定/ usr/include /的根目录中的所有内容是什么?

我知道其中一些是GNUC,这在某种程度上与std libc和libcxx libs截然不同?但不是全部吗?

任何帮助 - 非常感谢.

马科斯

How*_*ant 4

将其放在命令行上将输出已定义宏的列表:

-E -dM
Run Code Online (Sandbox Code Playgroud)