Control the -isystem option in clang from CmakeList.txt

54 Views Asked by At

When trying to compile fbthrift on my mac (version info: ProductName: macOS ProductVersion: 13.4.1 BuildVersion: 22F82) using Cmake and clang++, I got a bunch of compilation errors as below:

[build] /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/math.h:170:5: note: expanded from macro 'signbit'
[build]     ( sizeof(x) == sizeof(float)  ? __inline_signbitf((float)(x))  

and after investigation, it turns out to be the mix of the include from the brew and mac os developer tools that cause some of the conflicts.

Checking the clang command generated from the CmakeLists.txt, I found out the command was: [build] /usr/bin/clang++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_CONTEXT_DYN_LINK -DBOOST_CONTEXT_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_NO_LIB -DBOOST_REGEX_DYN_LINK -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_DYN_LINK -DBOOST_THREAD_NO_LIB -DFMT_SHARED -DGFLAGS_IS_A_DLL=0 -DTHRIFT_HAVE_LIBSNAPPY=0 -I/Users/kaiqu/Developer/fbthrift/. -I/Users/kaiqu/Developer/fbthrift/build -I/opt/homebrew/opt/openssl@3/include -isystem /opt/homebrew/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include -g -std=c++20 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -MD -MT thrift/annotation/CMakeFiles/thriftannotation.dir/gen-cpp2/cpp_data.cpp.o -MF thrift/annotation/CMakeFiles/thriftannotation.dir/gen-cpp2/cpp_data.cpp.o.d -o thrift/annotation/CMakeFiles/thriftannotation.dir/gen-cpp2/cpp_data.cpp.o -c /Users/kaiqu/Developer/fbthrift/build/thrift/annotation/gen-cpp2/cpp_data.cpp

As can be seen from the above, the -isystem includes both the headers in brew and ones in mac os developer tools. After removing those -isystem arguments and run the build command manually it was build successfully.

Is there anyway to turn off the isystem arguments manually from CmakeLists.txt?

0

There are 0 best solutions below