summaryrefslogtreecommitdiffstats
path: root/Source/cmCreateTestSourceList.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2021-02-24 17:21:57 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2021-02-24 18:33:28 (GMT)
commit136608dfec0552d5a49f4f414e6cafa920b53828 (patch)
treede7b4dd746148bf506552629ab98255f941cfae1 /Source/cmCreateTestSourceList.cxx
parentf3ce32969de1162e5fe37b1b3936dd84e3df2e38 (diff)
downloadCMake-136608dfec0552d5a49f4f414e6cafa920b53828.zip
CMake-136608dfec0552d5a49f4f414e6cafa920b53828.tar.gz
CMake-136608dfec0552d5a49f4f414e6cafa920b53828.tar.bz2
cmCreateTestSourceList: avoid generating duplicate declarations
This avoids warnings with `clang-tidy`'s `-readability-redundant-declaration` lint in generated source code.
Diffstat (limited to 'Source/cmCreateTestSourceList.cxx')
-rw-r--r--Source/cmCreateTestSourceList.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 3001ae0..a2fac73 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -90,10 +90,15 @@ bool cmCreateTestSourceList(std::vector<std::string> const& args,
std::replace(func_name.begin(), func_name.end(), ' ', '_');
std::replace(func_name.begin(), func_name.end(), '/', '_');
std::replace(func_name.begin(), func_name.end(), ':', '_');
+ bool already_declared =
+ std::find(tests_func_name.begin(), tests_func_name.end(), func_name) !=
+ tests_func_name.end();
tests_func_name.push_back(func_name);
- forwardDeclareCode += "int ";
- forwardDeclareCode += func_name;
- forwardDeclareCode += "(int, char*[]);\n";
+ if (!already_declared) {
+ forwardDeclareCode += "int ";
+ forwardDeclareCode += func_name;
+ forwardDeclareCode += "(int, char*[]);\n";
+ }
}
std::string functionMapCode;