mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
clang-tidy: allow OBJC and OBJCXX
This commit is contained in:
@@ -1260,9 +1260,11 @@ syn keyword cmakeVariable contained
|
|||||||
\ CMAKE_NOT_USING_CONFIG_FLAGS
|
\ CMAKE_NOT_USING_CONFIG_FLAGS
|
||||||
\ CMAKE_NO_BUILTIN_CHRPATH
|
\ CMAKE_NO_BUILTIN_CHRPATH
|
||||||
\ CMAKE_NO_SYSTEM_FROM_IMPORTED
|
\ CMAKE_NO_SYSTEM_FROM_IMPORTED
|
||||||
|
\ CMAKE_OBJCXX_CLANG_TIDY
|
||||||
\ CMAKE_OBJCXX_EXTENSIONS
|
\ CMAKE_OBJCXX_EXTENSIONS
|
||||||
\ CMAKE_OBJCXX_STANDARD
|
\ CMAKE_OBJCXX_STANDARD
|
||||||
\ CMAKE_OBJCXX_STANDARD_REQUIRED
|
\ CMAKE_OBJCXX_STANDARD_REQUIRED
|
||||||
|
\ CMAKE_OBJC_CLANG_TIDY
|
||||||
\ CMAKE_OBJC_EXTENSIONS
|
\ CMAKE_OBJC_EXTENSIONS
|
||||||
\ CMAKE_OBJC_STANDARD
|
\ CMAKE_OBJC_STANDARD
|
||||||
\ CMAKE_OBJC_STANDARD_REQUIRED
|
\ CMAKE_OBJC_STANDARD_REQUIRED
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
|
||||||
This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``.
|
This property is implemented only when ``<LANG>`` is ``C``, ``CXX``, ``OBJC`` or ``OBJCXX``.
|
||||||
|
|
||||||
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command
|
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command
|
||||||
line for the ``clang-tidy`` tool. The :ref:`Makefile Generators`
|
line for the ``clang-tidy`` tool. The :ref:`Makefile Generators`
|
||||||
|
|||||||
5
Help/release/dev/clang-tidy-objc.rst
Normal file
5
Help/release/dev/clang-tidy-objc.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
clang-tidy-objc
|
||||||
|
---------------
|
||||||
|
|
||||||
|
* The target property :prop_tgt:`<LANG>_CLANG_TIDY` and the associated
|
||||||
|
variable :variable:`CMAKE_<LANG>_CLANG_TIDY` learned to support OBJC and OBJCXX.
|
||||||
@@ -4,7 +4,7 @@ CMAKE_<LANG>_CLANG_TIDY
|
|||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
|
||||||
Default value for :prop_tgt:`<LANG>_CLANG_TIDY` target property
|
Default value for :prop_tgt:`<LANG>_CLANG_TIDY` target property
|
||||||
when ``<LANG>`` is ``C`` or ``CXX``.
|
when ``<LANG>`` is ``C``, ``CXX``, ``OBJC`` or ``OBJCXX``.
|
||||||
|
|
||||||
This variable is used to initialize the property on each target as it is
|
This variable is used to initialize the property on each target as it is
|
||||||
created. For example:
|
created. For example:
|
||||||
|
|||||||
@@ -873,15 +873,21 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maybe insert an include-what-you-use runner.
|
// Maybe insert an include-what-you-use runner.
|
||||||
if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
|
if (!compileCommands.empty() &&
|
||||||
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
|
(lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) {
|
||||||
cmProp iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
|
|
||||||
std::string const tidy_prop = lang + "_CLANG_TIDY";
|
std::string const tidy_prop = lang + "_CLANG_TIDY";
|
||||||
cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
|
cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
|
||||||
std::string const cpplint_prop = lang + "_CPPLINT";
|
cmProp iwyu = nullptr;
|
||||||
cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
|
cmProp cpplint = nullptr;
|
||||||
std::string const cppcheck_prop = lang + "_CPPCHECK";
|
cmProp cppcheck = nullptr;
|
||||||
cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
|
if (lang == "C" || lang == "CXX") {
|
||||||
|
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
|
||||||
|
iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
|
||||||
|
std::string const cpplint_prop = lang + "_CPPLINT";
|
||||||
|
cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
|
||||||
|
std::string const cppcheck_prop = lang + "_CPPCHECK";
|
||||||
|
cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
|
||||||
|
}
|
||||||
if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) ||
|
if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) ||
|
||||||
cmNonempty(cppcheck)) {
|
cmNonempty(cppcheck)) {
|
||||||
std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_co_compile";
|
std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_co_compile";
|
||||||
|
|||||||
@@ -824,15 +824,21 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maybe insert an include-what-you-use runner.
|
// Maybe insert an include-what-you-use runner.
|
||||||
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
|
if (!compileCmds.empty() &&
|
||||||
std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
|
(lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) {
|
||||||
cmProp iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
|
|
||||||
std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
|
std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
|
||||||
cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
|
cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
|
||||||
std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
|
cmProp iwyu = nullptr;
|
||||||
cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
|
cmProp cpplint = nullptr;
|
||||||
std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
|
cmProp cppcheck = nullptr;
|
||||||
cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
|
if (lang == "C" || lang == "CXX") {
|
||||||
|
std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
|
||||||
|
iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
|
||||||
|
std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
|
||||||
|
cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
|
||||||
|
std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
|
||||||
|
cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
|
||||||
|
}
|
||||||
if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) ||
|
if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) ||
|
||||||
cmNonempty(cppcheck)) {
|
cmNonempty(cppcheck)) {
|
||||||
std::string run_iwyu = cmStrCat(cmakeCmd, " -E __run_co_compile");
|
std::string run_iwyu = cmStrCat(cmakeCmd, " -E __run_co_compile");
|
||||||
|
|||||||
@@ -372,6 +372,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
|||||||
initProp("ISPC_INSTRUCTION_SETS");
|
initProp("ISPC_INSTRUCTION_SETS");
|
||||||
initProp("LINK_SEARCH_START_STATIC");
|
initProp("LINK_SEARCH_START_STATIC");
|
||||||
initProp("LINK_SEARCH_END_STATIC");
|
initProp("LINK_SEARCH_END_STATIC");
|
||||||
|
initProp("OBJC_CLANG_TIDY");
|
||||||
|
initProp("OBJCXX_CLANG_TIDY");
|
||||||
initProp("Swift_LANGUAGE_VERSION");
|
initProp("Swift_LANGUAGE_VERSION");
|
||||||
initProp("Swift_MODULE_DIRECTORY");
|
initProp("Swift_MODULE_DIRECTORY");
|
||||||
initProp("VS_JUST_MY_CODE_DEBUGGING");
|
initProp("VS_JUST_MY_CODE_DEBUGGING");
|
||||||
|
|||||||
1
Tests/RunCMake/ClangTidy/OBJC-Build-stdout.txt
Normal file
1
Tests/RunCMake/ClangTidy/OBJC-Build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Tests[/\]RunCMake[/\]ClangTidy[/\]main\.m:0:0: warning: message \[checker\]
|
||||||
1
Tests/RunCMake/ClangTidy/OBJC-launch-Build-stdout.txt
Normal file
1
Tests/RunCMake/ClangTidy/OBJC-launch-Build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Tests[/\]RunCMake[/\]ClangTidy[/\]main\.m:0:0: warning: message \[checker\]
|
||||||
3
Tests/RunCMake/ClangTidy/OBJC-launch.cmake
Normal file
3
Tests/RunCMake/ClangTidy/OBJC-launch.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set(CTEST_USE_LAUNCHERS 1)
|
||||||
|
include(CTestUseLaunchers)
|
||||||
|
include(OBJC.cmake)
|
||||||
3
Tests/RunCMake/ClangTidy/OBJC.cmake
Normal file
3
Tests/RunCMake/ClangTidy/OBJC.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
enable_language(OBJC)
|
||||||
|
set(CMAKE_OBJC_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
|
||||||
|
add_executable(main main.m)
|
||||||
1
Tests/RunCMake/ClangTidy/OBJCXX-Build-stdout.txt
Normal file
1
Tests/RunCMake/ClangTidy/OBJCXX-Build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Tests[/\]RunCMake[/\]ClangTidy[/\]main\.mm:0:0: warning: message \[checker\]
|
||||||
1
Tests/RunCMake/ClangTidy/OBJCXX-launch-Build-stdout.txt
Normal file
1
Tests/RunCMake/ClangTidy/OBJCXX-launch-Build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Tests[/\]RunCMake[/\]ClangTidy[/\]main\.mm:0:0: warning: message \[checker\]
|
||||||
3
Tests/RunCMake/ClangTidy/OBJCXX-launch.cmake
Normal file
3
Tests/RunCMake/ClangTidy/OBJCXX-launch.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set(CTEST_USE_LAUNCHERS 1)
|
||||||
|
include(CTestUseLaunchers)
|
||||||
|
include(OBJCXX.cmake)
|
||||||
3
Tests/RunCMake/ClangTidy/OBJCXX.cmake
Normal file
3
Tests/RunCMake/ClangTidy/OBJCXX.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
enable_language(OBJCXX)
|
||||||
|
set(CMAKE_OBJCXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
|
||||||
|
add_executable(main main.mm)
|
||||||
@@ -16,8 +16,16 @@ endfunction()
|
|||||||
|
|
||||||
run_tidy(C)
|
run_tidy(C)
|
||||||
run_tidy(CXX)
|
run_tidy(CXX)
|
||||||
|
if (APPLE)
|
||||||
|
run_tidy(OBJC)
|
||||||
|
run_tidy(OBJCXX)
|
||||||
|
endif()
|
||||||
if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
|
if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
|
||||||
run_tidy(C-launch)
|
run_tidy(C-launch)
|
||||||
run_tidy(CXX-launch)
|
run_tidy(CXX-launch)
|
||||||
|
if (APPLE)
|
||||||
|
run_tidy(OBJC-launch)
|
||||||
|
run_tidy(OBJCXX-launch)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
run_tidy(C-bad)
|
run_tidy(C-bad)
|
||||||
|
|||||||
4
Tests/RunCMake/ClangTidy/main.m
Normal file
4
Tests/RunCMake/ClangTidy/main.m
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
4
Tests/RunCMake/ClangTidy/main.mm
Normal file
4
Tests/RunCMake/ClangTidy/main.mm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user