RWTH-HPC / CMake-codecov

CMake module for code coverage
BSD 3-Clause "New" or "Revised" License
89 stars 34 forks source link

Fix issues with Mac OS #15

Closed rbost closed 4 years ago

rbost commented 6 years ago

This PR fixes #12 using @rene-aguirre's solution, and allows CMake-codecov to work perfectly on OS X.

By the way, thanks for the great work πŸ‘

rbost commented 6 years ago

Unfortunately, as the CI needs a Fortran compiler, and Homebrew fails to install it (issue with brew link gcc), the correctness of the fix cannot be checked with Travis.

alehaa commented 6 years ago

Thanks for this PR. As soon as I've fixed the CI environment, I'll merge it.

codecov-io commented 6 years ago

Codecov Report

Merging #15 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #15   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines          20     20           
=====================================
  Hits           20     20

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update 9a24e83...5640f42. Read the comment docs.

rbost commented 6 years ago

Sorry, I wanted to open a new PR with other changes, and I mixed things up big time ...

I will open a new PR for this fix + another PR for the new bug I found and fixed.

alehaa commented 6 years ago

I think that's okay, I can merge both. :)

rbost commented 6 years ago

I think that's okay, I can merge both. :)

Do you mean both commits or both PRs? :)

alehaa commented 6 years ago

Both commits in this PR.

rbost commented 6 years ago

Both commits in this PR.

Alright then. Let me just quickly explain what 1c30da6 does in a bit more details.

Suppose that you are using add_subdirectory(subdir), and that in the CMakeLists.txt file of subdir, you defined a target sub_target. If you call add_coverage(sub_target) from subdir's CMake file, everything is fine. But, if you do so from the root CMake file, you will run into errors from CMake-codecov because it expects files at some incorrect locations. This is because the target's source directory (TDIR) is computed from the current binary directory (CMAKE_CURRENT_BINARY_DIR) not the one of the target when it was defined. We can get it by calling the BINARY_DIR property on the target, and this is exactly what commit 1c30da6 does.