How to use CXX flags provided by llvm-config effectively?

524 Views Asked by At

I have a project that is built on top of LLVM. Now I am trying to come up with a CMakeLists file that would work on at least Mac OS, Ubuntu and CentOS platforms. For that I am using /opt/llvm-3.9/bin/llvm-config --libnames x86 ... to link my project with the libraries it needs and also I am considering to use llvm-config --cxxflags:

--cxxflags C++ compiler flags for files that include LLVM headers.

The problem, however is that llvm-config --cxxflags gives more flags that my library needs, specifically it adds -O3 which I definitely don't want to be there in Debug builds of my project:

/opt/llvm-3.9/bin/llvm-config --cxxflags

-I/opt/llvm-3.9/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -O3 -DNDEBUG -fno-exceptions -fno-rtti -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

It looks like --cxxflags gives the flags that LLVM itself was built with, not the flags it recommends me to use for my .cpp files.

This thread [LLVMdev] Ideas for making llvm-config --cxxflags more useful has my question in the beginning of it but ends up being nowhere.

What is the right way to pick up LLVM flags that my project might need for its files that link with LLVM?

0

There are 0 best solutions below