我正在尝试建立一个非常简单的回归模型,该模型(除其他外)将建立并编译GCC目标覆盖率,执行并随后发布标准的Cobertura覆盖率报告(均在Jenkins中)。 Jenkins部分在这里无关紧要,目前我只关心CMake语法。到目前为止,这是我的CMake文件:
cmake_minimum_required( VERSION 3.15 )
# Project's name
project( my_project )
# Set the output folder where your program will be created
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/test/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set( CMAKE_VERBOSE_MAKEFILE on )
# Generate coverage on GCC.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(LDFLAGS "${LDFLAGS} -lgcov -fprofile-arcs")
endif()
# Includes and Sources
include_directories(${PROJECT_SOURCE_DIR}/inc)
file(GLOB APP_SRC "./src/*.c")
file(GLOB TEST_DEPENDS_SRC "./test/src/*.c")
# Add executable to list.
add_executable( ${PROJECT_NAME}_Test ${APP_SRC} ${TEST_DEPENDS_SRC} )
这将在目录/test/build/gcc/CMakeFiles/my_project.dir/*中生成我的* .gcno和* .gcda文件,但是为了便于后期处理,我想我希望将这些文件放在其源代码旁边。那可能吗?如果是这样,怎么办?那是最佳实践吗?关于CMake,我还是很环保的。