cmake_modules/FindClang.cmake
author unc0rr
Sun, 14 Oct 2018 23:17:47 +0200
changeset 13922 a83ba9ba1566
parent 9246 75f430ebeb74
permissions -rw-r--r--
Start land2d library implementation: draw_line() method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9246
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     1
# - Try to find the Clang/LLVM executable
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     2
# Once done this will define
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     3
#
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     4
#  CLANG_FOUND       - system has Clang
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     5
#  CLANG_VERSION     - Clang version
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     6
#  CLANG_EXECUTABLE  - Clang executable
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     7
#
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     8
# Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
     9
#
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    10
# Redistribution and use is allowed according to the terms of the BSD license.
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    11
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    12
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    13
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
    14
        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
    15
        PATHS /opt/local/bin /usr/local/bin /usr/bin)
9246
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    16
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    17
if (CLANG_EXECUTABLE)
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    18
    execute_process(COMMAND ${CLANG_EXECUTABLE} --version
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    19
                    OUTPUT_VARIABLE CLANG_VERSION_OUTPUT
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    20
                    ERROR_VARIABLE CLANG_VERSION_ERROR
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    21
                    RESULT_VARIABLE CLANG_VERSION_RESULT
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    22
                    OUTPUT_STRIP_TRAILING_WHITESPACE
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    23
                    )
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    24
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    25
    if(${CLANG_VERSION_RESULT} EQUAL 0)
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    26
        string(REGEX MATCH "[0-9]+\\.[0-9]+" CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    27
        string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" CLANG_VERSION "${CLANG_VERSION}")
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    28
    else()
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    29
        message(SEND_ERROR "Command \"${CLANG_EXECUTABLE} --version\" failed with output: ${CLANG_VERSION_ERROR}")
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    30
    endif()
8113
0ad9c42dca7c Refactor Clang module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents: 8111
diff changeset
    31
endif()
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    32
9246
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    33
include(FindPackageHandleStandardArgs)
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    34
find_package_handle_standard_args(Clang DEFAULT_MSG CLANG_EXECUTABLE CLANG_VERSION)
75f430ebeb74 new FindClang.cmake
koda
parents: 9133
diff changeset
    35
mark_as_advanced(CLANG_VERSION)
8109
b5cd8cad2d86 Move code for Clang to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff changeset
    36