Closed giacomini closed 4 years ago
I've also just run into this issue. Actually get_filename_component() supports the parameter LAST_EXT which will then correctly return just the ".cpp" component of the filename (no need to a regex): https://cmake.org/cmake/help/latest/command/get_filename_component.html
This is just a one-line fix so I'll submit a pull request for this shortly.
Pull request submitted with a fix here: https://github.com/RWTH-HPC/CMake-codecov/pull/19
Merged #19.
Be careful, though, that LAST_EXT is available only in recent versions of CMake (3.14, I think).
This has been fixed in ea06ae7c840195e30563b0c71b8a11766b338a14.
Ok, fine with me, I can upgrade.
Some source code layout guidelines suggest to name test source files with the combined extension
.t.cpp
. Unfortunately the use ofget_filename_component
at https://github.com/RWTH-HPC/CMake-codecov/blob/9a24e83a901e4acee01786ff2c75559f580bb772/cmake/Findcodecov.cmake#L136 is not adequate in such a situation, because it extracts the maximal extension.t.cpp
instead of just.cpp
, which makes the source file not recognizable.An alternative would be the use of a regular expression, i.e. instead of:
one could use