1

我有项目文件,我有一个测试,我有一个 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]

我无法理解,为什么?我在“包含目录”中添加了包含和内容。如何让球滚动?

谢谢

4

1 回答 1

0

我相信这是路径中的一些错误。也许是一些小错字,它应该像 googletests/googletest S之类的。最好的检查方法是RDP 构建工人并检查什么是真实路径。

于 2016-11-28T06:58:08.667 回答