From 4a7ca383b4484762c2c7c1ecc720e79b40573f8e Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 18 Apr 2020 16:38:31 +0200 Subject: [PATCH] Adjust some error/warning messages and fix include directories --- Clang.cmake | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/Clang.cmake b/Clang.cmake index b724eb1..152ef37 100644 --- a/Clang.cmake +++ b/Clang.cmake @@ -62,7 +62,7 @@ function(string_append_target_includes) # Scan linked libraries as well. get_target_property(_els ${_target} LINK_LIBRARIES) foreach(_lib ${_els}) - #string_append_target_includes(LINKED TARGET "${_lib}" OUTPUT "_out" PREFIX "${_ARGS_PREFIX}") + string_append_target_includes(LINKED TARGET "${_lib}" OUTPUT "_out" PREFIX "${_ARGS_PREFIX}") endforeach() endif() elseif((${target_type} STREQUAL "INTERFACE_LIBRARY")) @@ -70,7 +70,7 @@ function(string_append_target_includes) set(test "$<$:${_ARGS_PREFIX}$>") set(_out "${_out}${test} ") else() - message("clang: Unsupported Target type '${target_type}', please open an issue for this.") + message("Clang for CMake: Unsupported Target type '${target_type}', please open an issue for this.") endif() endif() @@ -100,11 +100,11 @@ function(generate_compile_commands_json) set(COMPILER_INCLUDE_PREFIX "-I") set(COMPILER_DEFINE_PREFIX "-D") else() - message("clang-tidy: C ID '${CMAKE_C_COMPILER_ID}'") - message("clang-tidy: C Version '${CMAKE_C_COMPILER_VERSION}'") - message("clang-tidy: C++ ID '${CMAKE_CXX_COMPILER_ID}'") - message("clang-tidy: C++ Version '${CMAKE_CXX_COMPILER_VERSION}'") - message(FATAL_ERROR "clang-tidy: Current Compiler is not yet supported, please open an issue for it.") + message("Clang for CMake: C ID '${CMAKE_C_COMPILER_ID}'") + message("Clang for CMake: C Version '${CMAKE_C_COMPILER_VERSION}'") + message("Clang for CMake: C++ ID '${CMAKE_CXX_COMPILER_ID}'") + message("Clang for CMake: C++ Version '${CMAKE_CXX_COMPILER_VERSION}'") + message(FATAL_ERROR "Clang for CMake: Current Compiler is not yet supported, please open an issue for it.") endif() # Default Filter @@ -144,10 +144,8 @@ function(generate_compile_commands_json) string(APPEND COMPILER_OPTIONS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} ") ## C++ Standard get_target_property(_el ${_target} CXX_STANDARD) - if(COMPILER_TAG STREQUAL "MSVC") - if(${MSVC_VERSION} LESS "1920") - message(FATAL_ERROR "clang-tidy: Current Compiler is not yet supported, please open an issue for it.") - else() + if(COMPILER_TAG STREQUAL "MSVC") + if(${MSVC_VERSION} GREATER_EQUAL "1920") if((_el EQUAL 98) OR (_el EQUAL 11)) # Nothing to do, this is the default. elseif(_el EQUAL 14) @@ -157,6 +155,22 @@ function(generate_compile_commands_json) elseif(_el EQUAL 20) string(APPEND COMPILER_OPTIONS "/std:c++latest ") endif() + elseif(${MSVC_VERSION} GREATER_EQUAL "1910") + if((_el EQUAL 98) OR (_el EQUAL 11)) + # Nothing to do, this is the default. + elseif(_el EQUAL 14) + string(APPEND COMPILER_OPTIONS "/std:c++14 ") + elseif(_el EQUAL 17) + string(APPEND COMPILER_OPTIONS "/std:c++17 ") + elseif(_el EQUAL 20) + string(APPEND COMPILER_OPTIONS "/std:c++latest ") + endif() + else() + message("Clang for CMake: C ID '${CMAKE_C_COMPILER_ID}'") + message("Clang for CMake: C Version '${CMAKE_C_COMPILER_VERSION}'") + message("Clang for CMake: C++ ID '${CMAKE_CXX_COMPILER_ID}'") + message("Clang for CMake: C++ Version '${CMAKE_CXX_COMPILER_VERSION}'") + message(FATAL_ERROR "Clang for CMake: Current Compiler is not yet supported, please open an issue for it.") endif() elseif((COMPILER_TAG STREQUAL "CLANG") OR (COMPILER_TAG STREQUAL "GNU")) if(_el EQUAL 98) @@ -240,7 +254,7 @@ function(clang_format) bin32 ) if(NOT CLANG_FORMAT_BIN) - message(WARNING "Clang: Could not find clang-format at path '${CLANG_FORMAT_BIN}', disabling clang-format...") + message(WARNING "Clang for CMake: Could not find clang-format at path '${CLANG_FORMAT_BIN}', disabling clang-format...") return() endif() @@ -257,12 +271,12 @@ function(clang_format) ERROR_QUIET ) if(NOT _VERSION_RESULT EQUAL 0) - message(WARNING "Clang: Could not discover version, disabling clang-format...") + message(WARNING "Clang for CMake: Could not discover version, disabling clang-format...") return() endif() string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" _VERSION_MATCH ${_VERSION_OUTPUT}) if(NOT ${_VERSION_MATCH} VERSION_GREATER_EQUAL ${_ARGS_VERSION}) - message(WARNING "Clang: Old version discovered, disabling clang-format...") + message(WARNING "Clang for CMake: Old version discovered, disabling clang-format...") return() endif() endif() @@ -338,7 +352,7 @@ function(clang_tidy) bin32 ) if(NOT CLANG_TIDY_BIN) - message(WARNING "Clang: Could not find clang-tidy at path '${CLANG_TIDY_BIN}', disabling clang-tidy...") + message(WARNING "Clang for CMake: Could not find clang-tidy at path '${CLANG_TIDY_BIN}', disabling clang-tidy...") return() endif() @@ -355,12 +369,12 @@ function(clang_tidy) ERROR_QUIET ) if(NOT _VERSION_RESULT EQUAL 0) - message(WARNING "Clang: Could not discover version, disabling clang-tidy...") + message(WARNING "Clang for CMake: Could not discover version, disabling clang-tidy...") return() endif() string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" _VERSION_MATCH ${_VERSION_OUTPUT}) if(NOT ${_VERSION_MATCH} VERSION_GREATER_EQUAL ${_ARGS_VERSION}) - message(WARNING "Clang: Old version discovered, disabling clang-tidy...") + message(WARNING "Clang for CMake: Old version discovered, disabling clang-tidy...") return() endif() endif()