From 775c369420ece1500c2de46b83d5564480d05f70 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Fri, 12 May 2023 16:53:32 +0200 Subject: Autogen: set SKIP_LINTING ON for generated files Fixes: #19772 --- Source/cmQtAutoGenInitializer.cxx | 1 + .../RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt | 1 + Tests/RunCMake/Autogen/AutogenSkipLinting.cmake | 16 ++++++++++++++++ Tests/RunCMake/Autogen/RunCMakeTest.cmake | 15 +++++++++++++++ Tests/RunCMake/Autogen/SkipLinting.cxx | 6 ++++++ Tests/RunCMake/Autogen/SkipLinting.h | 11 +++++++++++ Tests/RunCMake/CMakeLists.txt | 4 ++++ 7 files changed, 54 insertions(+) create mode 100644 Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt create mode 100644 Tests/RunCMake/Autogen/AutogenSkipLinting.cmake create mode 100644 Tests/RunCMake/Autogen/SkipLinting.cxx create mode 100644 Tests/RunCMake/Autogen/SkipLinting.h diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index d897f0e..76bb0cd 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1834,6 +1834,7 @@ cmSourceFile* cmQtAutoGenInitializer::RegisterGeneratedSource( cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true); gFile->MarkAsGenerated(); gFile->SetProperty("SKIP_AUTOGEN", "1"); + gFile->SetProperty("SKIP_LINTING", "ON"); return gFile; } diff --git a/Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt b/Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/Autogen/AutogenSkipLinting.cmake b/Tests/RunCMake/Autogen/AutogenSkipLinting.cmake new file mode 100644 index 0000000..3ce2092 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutogenSkipLinting.cmake @@ -0,0 +1,16 @@ +enable_language(CXX) + +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "$<1:${PSEUDO_IWYU}>" -some -args) +set(CMAKE_CXX_CLANG_TIDY "$<1:${PSEUDO_TIDY}>" -bad) +set(CMAKE_CXX_CPPLINT "$<1:${PSEUDO_CPPLINT}>" --error) +set(CMAKE_CXX_CPPCHECK "$<1:${PSEUDO_CPPCHECK}>" -error) + +add_executable(SkipLinting SkipLinting.cxx SkipLinting.h) +set_source_files_properties(SkipLinting.cxx PROPERTIES SKIP_LINTING TRUE) + +target_link_libraries(SkipLinting Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index 4505132..97b64ed 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -87,5 +87,20 @@ if (DEFINED with_qt_version) message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") run_cmake_command(AutogenUseSystemIncludeOff ${CMAKE_COMMAND} --build . --config Debug --verbose) endblock() + + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenSkipLinting-build) + list(APPEND RunCMake_TEST_OPTIONS + "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}" + "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}" + "-DPSEUDO_IWYU=${PSEUDO_IWYU}" + "-DPSEUDO_TIDY=${PSEUDO_TIDY}") + + run_cmake(AutogenSkipLinting) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(AutogenSkipLinting-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + endif() endif() endif () diff --git a/Tests/RunCMake/Autogen/SkipLinting.cxx b/Tests/RunCMake/Autogen/SkipLinting.cxx new file mode 100644 index 0000000..9e09b27 --- /dev/null +++ b/Tests/RunCMake/Autogen/SkipLinting.cxx @@ -0,0 +1,6 @@ +#include "SkipLinting.h" + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/Autogen/SkipLinting.h b/Tests/RunCMake/Autogen/SkipLinting.h new file mode 100644 index 0000000..def56a0 --- /dev/null +++ b/Tests/RunCMake/Autogen/SkipLinting.h @@ -0,0 +1,11 @@ +#ifndef SKIP_LINTING_H +#define SKIP_LINTING_H + +#include + +class SkipMe : public QObject +{ + Q_OBJECT +}; + +#endif diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index cea8cff..58f06de 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -266,6 +266,10 @@ if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND) -Dwith_qt_version=6 "-DQt6_DIR:PATH=${Qt6_DIR}" "-DCMAKE_PREFIX_PATH:STRING=${base_dir}" + -DPSEUDO_TIDY=$ + -DPSEUDO_IWYU=$ + -DPSEUDO_CPPLINT=$ + -DPSEUDO_CPPCHECK=$ ) set(want_NoQt_test FALSE) endif () -- cgit v0.12