Simplify lint setup.
Lint from 3rd-party libraries are 'suppressed' by having a separate '.clang-tidy' file with minimal checks enabled.
This commit is contained in:
parent
f0af72778a
commit
18cd3b3995
@ -731,9 +731,16 @@ else ()
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
|
||||
endif ()
|
||||
if (URHO3D_LINT)
|
||||
# Don't show any diagnostics while in linter mode
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
|
||||
find_program (CLANG_TIDY clang-tidy NO_CMAKE_FIND_ROOT_PATH)
|
||||
if (CLANG_TIDY)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
|
||||
set (CMAKE_C_CLANG_TIDY ${CLANG_TIDY} -config=)
|
||||
set (CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY} -config=)
|
||||
set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
else ()
|
||||
message (FATAL_ERROR "Ensure clang-tidy host tool is installed and can be found in the PATH environment variable.")
|
||||
endif ()
|
||||
endif ()
|
||||
if ((NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.1) OR (APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0))
|
||||
# Workaround for Clang 7.0.1 and above until the Bullet upstream has fixed the Clang 7 diagnostic checks issue (see https://github.com/bulletphysics/bullet3/issues/2114)
|
||||
@ -1856,26 +1863,6 @@ macro (setup_test)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Macro for setting up linter
|
||||
macro (setup_lint)
|
||||
if (URHO3D_LINT)
|
||||
find_program (CLANG_TIDY clang-tidy NO_CMAKE_FIND_ROOT_PATH)
|
||||
if (CLANG_TIDY)
|
||||
set (CMAKE_C_CLANG_TIDY ${CLANG_TIDY} -config=)
|
||||
set (CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY} -config=)
|
||||
set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
else ()
|
||||
message (FATAL_ERROR "Ensure clang-tidy host tool is installed and can be found in the PATH environment variable.")
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Macro for resetting the linter (intended to be called in a child scope where its parent scope has the linter setup)
|
||||
macro (reset_lint)
|
||||
unset (CMAKE_CXX_CLANG_TIDY)
|
||||
unset (CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||
endmacro ()
|
||||
|
||||
# Set common binary output directory if not already set (note that this module can be included in an external project which may already have DEST_RUNTIME_DIR preset)
|
||||
if (NOT DEST_RUNTIME_DIR)
|
||||
set_output_directories (${CMAKE_BINARY_DIR}/bin RUNTIME PDB)
|
||||
|
@ -23,8 +23,6 @@
|
||||
# Set project name
|
||||
project (Urho3D-Extras)
|
||||
|
||||
setup_lint ()
|
||||
|
||||
# Find Urho3D library
|
||||
find_package (Urho3D REQUIRED)
|
||||
include_directories (${URHO3D_INCLUDE_DIRS})
|
||||
|
@ -27,8 +27,6 @@ endif ()
|
||||
# Set project name
|
||||
project (Urho3D-Samples)
|
||||
|
||||
setup_lint ()
|
||||
|
||||
# Find Urho3D library
|
||||
find_package (Urho3D REQUIRED)
|
||||
include_directories (${URHO3D_INCLUDE_DIRS})
|
||||
|
4
Source/ThirdParty/Assimp/code/CMakeLists.txt
vendored
4
Source/ThirdParty/Assimp/code/CMakeLists.txt
vendored
@ -934,10 +934,6 @@ set (TARGET_NAME Assimp)
|
||||
# Define source files
|
||||
set (SOURCE_FILES ${assimp_src})
|
||||
|
||||
# This target is added as dependency for AssetImporter target which may have clang-tidy setup at that scope
|
||||
# So, revert that here in order to exclude Assimp linter warnings/errors from ours
|
||||
reset_lint ()
|
||||
|
||||
# Since we only build AssetImporter as a single-arch native tool, there is no point to build Assimp as universal binary library
|
||||
list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH YES)
|
||||
|
||||
|
@ -23,8 +23,6 @@
|
||||
# Set project name
|
||||
project (Urho3D-Tools)
|
||||
|
||||
setup_lint ()
|
||||
|
||||
# Find Urho3D library
|
||||
find_package (Urho3D REQUIRED)
|
||||
include_directories (${URHO3D_INCLUDE_DIRS})
|
||||
|
@ -23,8 +23,6 @@
|
||||
# Define target name
|
||||
set (TARGET_NAME Urho3D)
|
||||
|
||||
setup_lint ()
|
||||
|
||||
# Prevent ICE from old MinGW versions, workaround from the GCC bugzilla https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61189
|
||||
if (MINGW AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.1 AND NOT URHO3D_64BIT)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mpreferred-stack-boundary=2")
|
||||
|
Loading…
Reference in New Issue
Block a user