cmake_modules/FindClang.cmake
branchwebgl
changeset 8108 39d7a16ce60c
child 8111 4307de8780fa
equal deleted inserted replaced
8105:d088be5ecdcb 8108:39d7a16ce60c
       
     1 # Load LLVM/Clang
       
     2 IF (CLANG)
       
     3     SET(CLANG_EXECUTABLE ${CLANG})
       
     4 ELSE()
       
     5     FIND_PROGRAM(CLANG_EXECUTABLE
       
     6         NAMES clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang
       
     7         PATHS /opt/local/bin /usr/local/bin /usr/bin)
       
     8 ENDIF()
       
     9 
       
    10 # Check LLVM/Clang version
       
    11 IF (CLANG_EXECUTABLE)
       
    12     EXEC_PROGRAM(${CLANG_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE CLANG_VERSION_FULL)
       
    13 
       
    14     STRING(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION_LONG "${CLANG_VERSION_FULL}")
       
    15     STRING(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION_LONG}")
       
    16 
       
    17     # Required that LLVM/Clang version is >= 3.0
       
    18     IF (CLANG_VERSION VERSION_GREATER 3.0 OR CLANG_VERSION VERSION_EQUAL 3.0)
       
    19         MESSAGE(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
       
    20     ELSE()
       
    21         MESSAGE(FATAL_ERROR "Necessary LLVM/Clang version not found (version >= 3.0 required)")
       
    22     ENDIF()
       
    23 ELSE()
       
    24     MESSAGE(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
       
    25 ENDIF()
       
    26 
       
    27 SET(CMAKE_C_COMPILER ${CLANG_EXECUTABLE})