我有项目文件,我有一个测试,我有一个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]
我无法理解,为什么?我在" include目录"中添加了Include和stuff。怎么让球滚动?
由于
答案 0 :(得分:0)
我认为路径上有些错误。也许是一些小错字,它应该像googletests / googletest S 之类的东西。检查的最佳方法是RDP to build worker并检查什么是真实路径。