Skip to content

Using CMake-codecov with $<TARGET_OBJECTS:xxxxxxxx> #11

@Gjacquenot

Description

@Gjacquenot

I am facing a Coverage disabled warning while trying to use CMake-codecov.

I am building executable with TARGET_OBJECTS option, that prevent CMake-codecov to discover the language used. The internal variable NUM_COMPILERS is equal to zero in Findcodecov.cmake. Would it be possible to investigate this development?

ADD_EXECUTABLE(my_test_prog $<TARGET_OBJECTS:my_test_prog_obj>)
add_coverage(my_test_prog)

Below is a CMakeLists.txt, that repoduces the problem (one needs to have codecov available to CMake)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT(hello_world)
IF(NOT DEFINED CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE Coverage)
ENDIF()
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
IF(${CMAKE_BUILD_TYPE_UPPER} STREQUAL "COVERAGE")
    MESSAGE(STATUS "Adding coverage")
    SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # ;${CMAKE_MODULE_PATH}
    FIND_PACKAGE(codecov)
ENDIF()
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/my_test_prog.cpp"
"
#include <iostream>
using namespace std;
int main()
{
    cout << \"Hello World!\" << endl;
    return 0;
}
")

ADD_LIBRARY(my_test_prog_obj OBJECT ${CMAKE_CURRENT_BINARY_DIR}/my_test_prog.cpp)
ADD_EXECUTABLE(my_test_prog $<TARGET_OBJECTS:my_test_prog_obj>)
add_coverage(my_test_prog)

The log is here

-- Adding coverage
-- Try  code coverage flag = [-O0 -g -fprofile-arcs -ftest-coverage]
-- Try  code coverage flag = [-O0 -g --coverage]
CMake Warning (dev) at cmake/Findcodecov.cmake:174 (message):
  Coverage disabled for target my_test_prog because there is no sanitizer
  available for target sources.
Call Stack (most recent call first):
  cmake/Findcodecov.cmake:34 (add_coverage_target)
  CMakeLists.txt:25 (add_coverage)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: buildCoverage

#make
Scanning dependencies of target my_test_prog_obj
[ 50%] Building CXX object CMakeFiles/my_test_prog_obj.dir/my_test_prog.cpp.obj
[ 50%] Built target my_test_prog_obj
Scanning dependencies of target my_test_prog
[100%] Linking CXX executable my_test_prog.exe
[100%] Built target my_test_prog

Guillaume

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions