gpt4 book ai didi

c++ - AppVeyor 上带有 g-tests 的 Visual Studio 解决方案

转载 作者:太空宇宙 更新时间:2023-11-04 13:08:54 25 4
gpt4 key购买 nike

我有项目文件,我有一个测试,我有一个 CMakeLists.txt。我需要在 AppVeyor 上运行测试。而我是VS的门外汉。

我的appveyor.yml

    version: '{build}'

os: Visual Studio 2015
configuration:
- Release

build_script:
- mkdir build
- cd build
- cmake -Dgtest_build_samples=ON ..
- msbuild gtest-demo.sln

我的CMakeList.txt

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(gtest-demo)

enable_language(C)
enable_language(CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_CXX_FLAGS "-Wall -Wno-unknown-pragmas -Wno-sign-compare -Woverloaded-virtual -Wwrite-strings -Wno-unused")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

include_directories(
${PROJECT_SOURCE_DIR}/src
)

add_library(
example
src/vec2.cpp
src/obstacle.cpp
src/map.cpp
)

set(GOOGLETEST_ROOT googletests/googletest CACHE STRING "Google Test source root")

include_directories(
${PROJECT_SOURCE_DIR}/${GOOGLETEST_ROOT}
${PROJECT_SOURCE_DIR}/${GOOGLETEST_ROOT}/include
)

set(GOOGLETEST_SOURCES
${PROJECT_SOURCE_DIR}/${GOOGLETEST_ROOT}/src/gtest-all.cc
${PROJECT_SOURCE_DIR}/${GOOGLETEST_ROOT}/src/gtest_main.cc
)


#########################################################

foreach(_source ${GOOGLETEST_SOURCES})
set_source_files_properties(${_source} PROPERTIES GENERATED 1)
endforeach()
################################################3
add_library(googletest ${GOOGLETEST_SOURCES})

add_executable(
unit_tests
tests/main.cpp
tests/test.cpp
)

add_dependencies(unit_tests googletest)

target_link_libraries(
unit_tests
googletest
example
pthread
)

include(CTest)
enable_testing()

add_test(unit ${PROJECT_BINARY_DIR}/unit_tests)

和错误日志:

c1xx : fatal error C1083: Cannot open source file: 'C:\projects\gr-cl\googletests\googletest\src\gtest-all.cc': No such file or directory [C:\projects\gr-cl\build\googletest.vcxproj]
c1xx : fatal error C1083: Cannot open source file: 'C:\projects\gr-cl\googletests\googletest\src\gtest_main.cc': No such file or directory [C:\projects\gr-cl\build\googletest.vcxproj]

我不明白,为什么?我在“包含目录”中添加了包含和内容。如何让球滚动?

谢谢

最佳答案

我相信这是路径中的一些错误。也许是一些小的错字,它应该像 googletests/googletestS 之类的。最好的检查方法是 RDP to build worker并检查什么是真实路径。

关于c++ - AppVeyor 上带有 g-tests 的 Visual Studio 解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40830873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com