Package dependencies
Yum install the following packages:
cmake
clang
clang-devel
libffi
libffi-devel
llvm-devel
llvm-static
I understand Clang shares headers / libs with GNU g++ so I have assumed you already have g++ installed.
CMakeLists.txt
To allow the yum installed CMake to work I had to tweak the tutorial CMakeLists.txt to look like below:
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/lib64/llvm)
add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS)
project (Tutorial)
add_executable(Tutorial tutorial.cxx)
target_link_libraries(Tutorial /usr/lib64/llvm/libclang.so /usr/lib64/llvm/libLLVM-3.4.so /usr/lib64/llvm/liblldb.so /usr/lib64/llvm/libclangTooling.a)
Build and run
Simply do a "cmake ." followed by "make". This will build an executable called "Tutorial".
You can then just run Tutorial against tutorial.cxx.
compile_commands.json
My example invokes runToolOnCodeWithArgs(). To get the correct arguments you can enable verbose makefile:
cmake -DCMAKE_VERBOSE_MAKEFILE=ON .
This will cause a compile_commands.json to be output. This lists all the arguments you need to pass to Clang for the compilation unit to compile correctly.
Links:
CMakeList.txt - https://drive.google.com/open?id=0B_YZvz83_le0TGxuNlRkaC03LXM