cmake_modules/FindClang.cmake
author Bryan Dunsmore <dunsmoreb@gmail.com>
Sat, 01 Dec 2012 15:52:36 -0600
branchwebgl
changeset 8113 0ad9c42dca7c
parent 8111 4307de8780fa
child 8450 404ddce27b23
permissions -rw-r--r--
Refactor Clang module.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     1
# Load LLVM/Clang
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
     2
if (CLANG)
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
     3
    set(CLANG_EXECUTABLE ${CLANG})
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
     4
else()
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
     5
    find_program(CLANG_EXECUTABLE
8109
b5cd8cad2d86 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
b5cd8cad2d86 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)
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
     8
endif()
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
     9
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    10
# Check LLVM/Clang version
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    11
if (CLANG_EXECUTABLE)
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    12
    exec_program(${CLANG_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE CLANG_VERSION_FULL)
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    13
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    14
    string(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION_LONG "${CLANG_VERSION_FULL}")
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    15
    string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION_LONG}")
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    16
else()
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    17
    message(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    18
endif()
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    19
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    20
set(CMAKE_C_COMPILER ${CLANG_EXECUTABLE})