Skip to content

Make sure to get the resource directory from the right clang compiler #978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,30 @@ endif()
# Find Clang resource directory with Clang executable.

if(NOT CLANG_RESOURCE_DIR)
find_program(CLANG_EXECUTABLE clang)
find_program(CLANG_EXECUTABLE clang-${Clang_VERSION_MAJOR} NAMES clang)
if(NOT CLANG_EXECUTABLE)
message(FATAL_ERROR "clang executable not found.")
endif()

execute_process(
COMMAND ${CLANG_EXECUTABLE} -dumpversion
RESULT_VARIABLE CLANG_DUMP_VERSION_RESULT
OUTPUT_VARIABLE CLANG_DUMP_VERSION
ERROR_VARIABLE CLANG_DUMP_VERSION_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(CLANG_DUMP_VERSION_RESULT)
message(FATAL_ERROR "Error retrieving Clang executable version. \
Output:\n${CLANG_DUMP_VERSION_ERROR}")
endif()

if (NOT ${CLANG_DUMP_VERSION} STREQUAL ${Clang_VERSION})
message(FATAL_ERROR "Clang libraries and executable versions differs:\n\
librairies have version ${Clang_VERSION} and executable has version \
${CLANG_DUMP_VERSION}.")
endif()

execute_process(
COMMAND ${CLANG_EXECUTABLE} -print-resource-dir
RESULT_VARIABLE CLANG_FIND_RESOURCE_DIR_RESULT
Expand All @@ -147,7 +166,7 @@ if(NOT CLANG_RESOURCE_DIR)

if(CLANG_FIND_RESOURCE_DIR_RESULT)
message(FATAL_ERROR "Error retrieving Clang resource directory with Clang \
executable. Output:\n ${CLANG_FIND_RESOURCE_DIR_ERROR}")
executable. Output:\n${CLANG_FIND_RESOURCE_DIR_ERROR}")
endif()
endif()

Expand Down