cmake_modules/FindClang.cmake
author Bryan Dunsmore <dunsmoreb@gmail.com>
Fri, 30 Nov 2012 20:04:15 -0600
branchwebgl
changeset 8108 39d7a16ce60c
child 8111 4307de8780fa
permissions -rw-r--r--
Move code for Clang to separate CMake module.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8108
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     1
# Load LLVM/Clang
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     2
IF (CLANG)
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     3
    SET(CLANG_EXECUTABLE ${CLANG})
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     4
ELSE()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     5
    FIND_PROGRAM(CLANG_EXECUTABLE
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     6
        NAMES clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     7
        PATHS /opt/local/bin /usr/local/bin /usr/bin)
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     8
ENDIF()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     9
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    10
# Check LLVM/Clang version
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    11
IF (CLANG_EXECUTABLE)
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    12
    EXEC_PROGRAM(${CLANG_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE CLANG_VERSION_FULL)
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    13
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    14
    STRING(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION_LONG "${CLANG_VERSION_FULL}")
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    15
    STRING(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION_LONG}")
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    16
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    17
    # Required that LLVM/Clang version is >= 3.0
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    18
    IF (CLANG_VERSION VERSION_GREATER 3.0 OR CLANG_VERSION VERSION_EQUAL 3.0)
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    19
        MESSAGE(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    20
    ELSE()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    21
        MESSAGE(FATAL_ERROR "Necessary LLVM/Clang version not found (version >= 3.0 required)")
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    22
    ENDIF()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    23
ELSE()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    24
    MESSAGE(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    25
ENDIF()
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    26
39d7a16ce60c Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    27
SET(CMAKE_C_COMPILER ${CLANG_EXECUTABLE})