cmake_modules/FindClang.cmake
author koda
Wed, 20 Feb 2013 02:21:58 +0100
branchwebgl
changeset 8450 404ddce27b23
parent 8113 0ad9c42dca7c
child 9133 a269fe7090a0
permissions -rw-r--r--
add support for clang 3.3 (although there has to be a better way for this) and output right version number
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
8450
404ddce27b23 add support for clang 3.3 (although there has to be a better way for this) and output right version number
koda
parents: 8113
diff changeset
     6
        NAMES clang-mp-3.3 clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang
8109
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})