Open khrykin opened 5 years ago
Something must have gone wrong when trying to find it. It will look in different places including the PATH however.
Either way you can always change your settings by going to Settings -> Language & Frameworks -> C/C++ Coverage where you can set the needed tools for each of your toolchains
I looked there, but I have only gcov
option...
It seems Apple Clang gets detected as GCC by the plugin.
Default clang path on macOS is actually for the
alias which is c++
, not clang
, so this check doesn't pass:
https://github.com/zero9178/C-Cpp-Coverage-for-CLion/blob/7923276bd426f05a66d7fc20d47402ec7c1c6410/src/main/kotlin/net/zero9178/cov/settings/CoverageGeneratorSettings.kt#L219
I am not sure how to handle this as c++ is also a common name for GCC and people also still that on MacOS too. I could try doing --version first on the compiler. Biggest problem is probably that I do not have a mac to test however.
The gcov field there is actually not fixed however and you can replace the path with llvm-cov and afterwards the llvm-profdata and optional demangler fields will appear.
In hand sight I probably shouldn't make the label display either gcov or llvm-cov but rather both to avoid such problems
@zero9178, yeah, --version check would be more reliable.
I was able to workaround this by changing the compiler path in my toolchain to clang++
(which is the same alias). Still, I think the issue is worth fixing.
@khrykin I had the same issue as you. Changing the C++ compiler in "Build, Execution, Deployment" → "Toolchains" to /usr/bin/clang++
seems to work. Thanks!
However, now after running my Google Tests with Coverage I receive an error: "Coverage could not be generated due to following error: No executable specified" (see this line).
The configuration I use to run the tests looks as follow:
I also tried to run a normal (non-testing) configuration with the coverage. However, it returns the same error.
Did you have the same issue and if yes, how did you solve it? Thanks a lot!
@pjattke on macOS I use Clang provided by XCode, which is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
. CMAKE_CXX_COMPILER_ID
for it will be 'AppleClang', not 'Clang', so I changed the STREQUAL
to MATCHES
in the CMake code from the README:
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate)
#Uncomment in case of linker errors
#link_libraries(clang_rt.profile-x86_64)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(--coverage)
#Uncomment in case of linker errors
#link_libraries(gcov)
endif ()
This probably causes your issue.
@khrykin Thank you, now it works! The llvm-cov
path under Preferences → Languages & Frameworks → C/C++Coverage was not configured either. I copied the paths already specified at Build, Execution, Deployment → Coverage to make it work.
I'm getting this error on macOS 10.14.5 with Apple Clang:
However, both
lvm-profdata
andllvm-cov
are in my PATH, and I'm able to generate coverage manually in terminal.Can you please point me to a solution here?