diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-02-24 17:21:57 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2021-02-24 18:33:28 (GMT) |
commit | 136608dfec0552d5a49f4f414e6cafa920b53828 (patch) | |
tree | de7b4dd746148bf506552629ab98255f941cfae1 /Source/cmCreateTestSourceList.cxx | |
parent | f3ce32969de1162e5fe37b1b3936dd84e3df2e38 (diff) | |
download | CMake-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.cxx | 11 |
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; |