Switch to -print-resource-dir (drop support for system clang 4.0)

This commit is contained in:
Daan De Meyer 2018-03-26 16:24:05 +02:00 committed by Jacob Dufault
parent 9c729e1937
commit 401d542ba7

View File

@ -99,23 +99,9 @@ endif()
_Clang_find_program(Clang_EXECUTABLE clang) _Clang_find_program(Clang_EXECUTABLE clang)
if(Clang_EXECUTABLE) if(Clang_EXECUTABLE)
# Find Clang resource directory with Clang executable # Find Clang resource directory with Clang executable
# TODO: simplify by using -print-resource-dir once Clang 4 support is dropped execute_process(COMMAND ${Clang_EXECUTABLE} -print-resource-dir
if(${CMAKE_SYSTEM_NAME} STREQUAL Windows) OUTPUT_VARIABLE Clang_RESOURCE_DIR
set(_DEV_NULL NUL) OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(_DEV_NULL /dev/null)
endif()
# clang "-###" -xc /dev/null
execute_process(COMMAND ${Clang_EXECUTABLE} "-###" -xc ${_DEV_NULL}
ERROR_VARIABLE Clang_RESOURCE_DIR OUTPUT_QUIET)
# Strip everything except '"-resource-dir" "<resource-dir-path>"'
string(REGEX MATCH "\"-resource-dir\" \"([^\"]*)\""
Clang_RESOURCE_DIR ${Clang_RESOURCE_DIR})
# Strip quotes
string(REPLACE "\"" "" Clang_RESOURCE_DIR ${Clang_RESOURCE_DIR})
# Strip '-resource-dir '
string(REPLACE "-resource-dir " "" Clang_RESOURCE_DIR ${Clang_RESOURCE_DIR})
# Find Clang version # Find Clang version
set(_Clang_VERSION_REGEX "([0-9]+)\\.([0-9]+)\\.([0-9]+)") set(_Clang_VERSION_REGEX "([0-9]+)\\.([0-9]+)\\.([0-9]+)")