diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 7f27d4dd..8db896a0 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -347,30 +347,40 @@ if(CMAKE_COMPILER_IS_CLANG) OUTPUT_VARIABLE clang_search_dirs RESULT_VARIABLE clang_probe_result ERROR_QUIET) unset(clang_bindirs) + unset(clang_bindirs_x) unset(clang_libdirs) + unset(clang_libdirs_x) if(clang_probe_result EQUAL 0) - string(REGEX MATCH "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs}) - if(regexp_valid) - string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs}) - string(REPLACE ":" ";" list "${list}") - #set(clang_bindirs "") - foreach(dir IN LISTS list) - get_filename_component(dir "${dir}" REALPATH) + string(REGEX MATCH "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs}) + if(regexp_valid) + string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs}) + string(REPLACE ":" ";" list "${list}") + foreach(dir IN LISTS list) + get_filename_component(dir "${dir}" REALPATH) + if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*") list(APPEND clang_bindirs "${dir}") - endforeach() - list(REMOVE_DUPLICATES clang_bindirs) - endif() - string(REGEX MATCH "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs}) - if(regexp_valid) - string(REGEX REPLACE "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs}) - string(REPLACE ":" ";" list "${list}") - #set(clang_libdirs "") - foreach(dir IN LISTS list) - get_filename_component(dir "${dir}" REALPATH) + else() + list(APPEND clang_bindirs_x "${dir}") + endif() + endforeach() + list(APPEND clang_bindirs "${clang_bindirs_x}") + list(REMOVE_DUPLICATES clang_bindirs) + endif() + string(REGEX MATCH "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs}) + if(regexp_valid) + string(REGEX REPLACE "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs}) + string(REPLACE ":" ";" list "${list}") + foreach(dir IN LISTS list) + get_filename_component(dir "${dir}" REALPATH) + if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*") list(APPEND clang_libdirs "${dir}") - endforeach() - list(REMOVE_DUPLICATES clang_libdirs) - endif() + else() + list(APPEND clang_libdirs_x "${dir}") + endif() + endforeach() + list(APPEND clang_libdirs "${clang_libdirs_x}") + list(REMOVE_DUPLICATES clang_libdirs) + endif() else() get_filename_component(clang_bindirs ${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER} DIRECTORY) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")