CMake disable -std = C ++ 11 flag for C files

I am trying to build bkchaind . One build option is to use cmake, so I installed it using Homebrew (OSX 10.9.1). When I do cmake , I get:

 [ 2%] Building C object json-rpc-cpp/src/jsonrpc/CMakeFiles/jsonrpcStatic.dir/connectors/mongoose.co error: invalid argument '-std=c++11' not allowed with 'C/ObjC' 

I'm not sure why cmake will try to pass the C ++ - specific compiler option to the C / ObjC file. If I comment on this line in the main CMakeLists.txt file:

 ADD_DEFINITIONS(-std=c++11) 

then it no longer passes the flag to any file. However, C ++ files are really needed. How do I get cmake to enable a flag for C ++ files, but not for C files?

+7
c ++ c ++ 11 build cmake
source share
1 answer

Use CMAKE_CXX_FLAGS to set specific C ++ flags:

 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
+10
source share

All Articles