diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f9bbe1fd5..1ad982ae3d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,6 +259,28 @@ else() set(WITH_UNITY_BUILD OFF) endif() +if(COMMAND target_precompile_headers) + # Disabling is needed for `./tools/utils_maintenance/code_clean.py` to function. + option(WITH_COMPILER_PRECOMPILED_HEADERS "\ +Use pre-compiled headers to speed up compilation." + ON + ) + mark_as_advanced(WITH_COMPILER_PRECOMPILED_HEADERS) + + if(WITH_CLANG_TIDY AND CMAKE_COMPILER_IS_GNUCC) + if(WITH_COMPILER_PRECOMPILED_HEADERS) + message(STATUS + "Clang-Tidy and GCC precompiled headers are incompatible, disabling precompiled headers" + ) + set(WITH_COMPILER_PRECOMPILED_HEADERS OFF) + endif() + endif() + + if(NOT WITH_COMPILER_PRECOMPILED_HEADERS) + set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON) + endif() +endif() + option(WITH_IK_ITASC "\ Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d86c28443d9..fa48d6be171 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -7,14 +7,6 @@ if(WITH_LEGACY_OPENGL) endif() if(WITH_CLANG_TIDY AND NOT MSVC) - if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") - message(WARNING "Currently Clang-Tidy might fail with GCC toolchain, switch to Clang toolchain if that happens") - if(COMMAND target_precompile_headers) - message(STATUS "Clang-Tidy and GCC precompiled headers are incompatible, disabling precompiled headers") - set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON) - endif() - endif() - find_package(ClangTidy REQUIRED) set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE};--extra-arg=-Wno-error=unknown-warning-option) diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index 7d926c2b92f..df6331dc92b 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -327,7 +327,7 @@ def process_commands(cmake_dir: str, data: Sequence[str]) -> Optional[ProcessedC return None # Check for unsupported configurations. - for arg in ("WITH_UNITY_BUILD", "WITH_COMPILER_CCACHE"): + for arg in ("WITH_UNITY_BUILD", "WITH_COMPILER_CCACHE", "WITH_COMPILER_PRECOMPILED_HEADERS"): if cmake_cache_var_is_true(cmake_cache_var(cmake_dir, arg)): sys.stderr.write("The option '%s' must be disabled for proper functionality\n" % arg) return None