Respects USE_CLANG_COMPLETER flag in CMake build

If USE_CLANG_COMPLETER is ON, will try to use the system clang, and if
the version is not the minimum required or not present, download.
This commit is contained in:
Zeh Rizzatti 2013-02-07 23:13:55 -03:00 committed by Strahinja Val Markovic
parent 3b4eeee686
commit 2f3303e050

View File

@ -34,14 +34,15 @@ option( USE_SYSTEM_LIBCLANG "Set to ON to use the system libclang library" OFF )
option( EXTERNAL_LIBCLANG_PATH "Path libclang library to use" )
# Checks for clang 3.2 (LLVM 4.2+)
if ( NOT USE_SYSTEM_LIBCLANG AND NOT PATH_TO_LLVM_ROOT )
# Are we using it?
if ( COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.1 )
set( USE_SYSTEM_LIBCLANG ON )
if ( USE_CLANG_COMPLETER AND NOT USE_SYSTEM_LIBCLANG AND NOT PATH_TO_LLVM_ROOT )
# Figure out Clang version
if ( COMPILER_IS_CLANG )
set( CLANG_VERSION ${CMAKE_CXX_COMPILER_VERSION} )
else()
# If not using it, is it in the system and the right version?
execute_process( COMMAND clang -dumpversion OUTPUT_VARIABLE CLANG_VERSION )
if ( CLANG_VERSION VERSION_GREATER 4.1 )
endif()
if ( CLANG_VERSION VERSION_EQUAL 4.2 OR CLANG_VERSION VERSION_GREATER 4.2 )
# Good enough, use it.
set( USE_SYSTEM_LIBCLANG ON )
else() # If the wrong version, or not found, download
message( "Downloading Clang 3.2" )
@ -62,7 +63,6 @@ if ( NOT USE_SYSTEM_LIBCLANG AND NOT PATH_TO_LLVM_ROOT )
# And set PATH_TO_LLVM_ROOT
set( PATH_TO_LLVM_ROOT "${CMAKE_CURRENT_BINARY_DIR}/../${CLANG_DIRNAME}" )
endif()
endif()
endif()
if ( PATH_TO_LLVM_ROOT OR USE_SYSTEM_LIBCLANG OR EXTERNAL_LIBCLANG_PATH )