Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix relative paths #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmake/CoverallsGenerateGcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,18 @@ foreach (GCOV_FILE ${ALL_GCOV_FILES})
# ->
# /path/to/project/root/subdir/the_file.c
get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
# message("========== original file path: ${GCOV_SRC_PATH}")
if(${GCOV_SRC_PATH} MATCHES "^\\/.*")
set(GCOV_SRC_ABS_PATH "${GCOV_SRC_PATH}")
else()
if(${GCOV_SRC_PATH} MATCHES "\\^.*")
string(REGEX REPLACE "\\^" ".." GCOV_SRC_PATH "${GCOV_SRC_PATH}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can ve really rely on it always being .. here? Isn't this dependent on where you place your build folder?

For example. I mean the usual is to have it under project_root/build/ so then ../ would be project_root/ ... But what if the build folder is completly outside of the project_root does this still work then?

Copy link
Author

@konserw konserw Apr 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can ve really rely on it always being .. here?

I'm not sure to be honest. I've got the ^ only as .. and only in front of path, for instance ^/include/cucumber-cpp/internal/drivers/GTestDriver.hpp is in fact ../include/cucumber-cpp/internal/drivers/GTestDriver.hpp

I mean the usual is to have it under project_root/build/

And this is also my case

. But what if the build folder is completly outside of the project_root does this still work then

Haven't checked

Because I'm wondering it this would belong better in this macro maybe?

Yes - later on I've moved it to that macro, just forgot to update this branch also

endif()
get_filename_component(GCOV_SRC_ABS_PATH "${GCOV_SRC_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
endif()
# message("========== absolute file path: ${GCOV_SRC_ABS_PATH}")
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_ABS_PATH}")
# message("========== relative file path: ${GCOV_SRC_REL_PATH}")

# Is this in the list of source files?
# TODO: We want to match against relative path filenames from the source file root...
Expand Down