Switching between GCC and Clang/LLVM using CMake

I have a number of projects built using CMake and I’d like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I’m mistaken!) that to use Clang I need to set the following: SET (CMAKE_C_COMPILER “/usr/bin/clang”) SET (CMAKE_C_FLAGS “-Wall -std=c99”) SET (CMAKE_C_FLAGS_DEBUG “-g”) SET … Read more

How do I activate C++ 11 in CMake?

When I try to run a CMake generated makefile to compile my program, I get the error that range based for loops are not supported in C++ 98 mode. I tried adding add_definitions(-std=c++0x) to my CMakeLists.txt, but it did not help. I tried this too: if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-std=gnu++0x) endif() When I do g++ –version, I get: … Read more

Debug vs Release in CMake

In a GCC compiled project, How do I run CMake for each target type (debug/release)? How do I specify debug and release C/C++ flags using CMake? How do I express that the main executable will be compiled with g++ and one nested library with gcc? 6 s 6