这是我的测试装置:https://github.com/patrykbajos/ZinotEngine/blob/master/src/tests/core/MapResMgrTest.cpp。此可执行文件的CMake文件:对于所有可执行文件https://github.com/patrykbajos/ZinotEngine/blob/master/CMakeLists.txt,分别为https://github.com/patrykbajos/ZinotEngine/blob/master/ZinotEngine.cmake和CMakeLists。我已经在Ubuntu上的apt-get包libgtest-dev中编译了gtest。接下来,我将*.so文件复制到/usr/lib并安装了libgtest-dev packege,因为包含文件。我认为我的测试夹具是正确的。没有编译错误。我的exec通常会运行并显示:
/home/patryk/ClionProjects/BennuEngine/bin/Debug/ZinotEngine
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[ PASSED ] 0 tests.
Hello world!!!
Process finished with exit code 0 我已经在CMake文件中添加了一些行,但我认为它不会添加包含测试的*.cpp文件来构建可执行文件。下面是几行代码:
# Sources
file(GLOB_RECURSE ZINOTENGINE_SRC "src/zinot/core/*.c" "src/zinot/core/*.cpp")
file(GLOB_RECURSE ZINOTENGINETESTS_SRC "src/tests/*.cpp")
if (CMAKE_BUILD_TYPE EQUAL "Debug")
message("Debug << dodawanie testów.")
set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC} ${ZINOTENGINETESTS_SRC}")
endif ()
# Binary
add_executable(ZinotEngine ${ZINOTENGINE_SRC})它是我的整个代码库:https://github.com/patrykbajos/ZinotEngine。
PS。我正在用CLion和Configuration: Debug在Build All上编译我的项目。
发布于 2016-04-19 00:01:01
我找到窃听器了。它是在:
if (CMAKE_BUILD_TYPE EQUAL "Debug")
message("Debug << dodawanie testów.")
set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC} ${ZINOTENGINETESTS_SRC}")
endif ()它应该是:
if (CMAKE_BUILD_TYPE MATCHES Debug)
#message("Debug << dodawanie testów.")
set(ZINOTENGINE_SRC "${ZINOTENGINE_SRC};${ZINOTENGINETESTS_SRC}")
endif ()我认为源文件的分隔符是空格,但它是分号。
https://stackoverflow.com/questions/36697847
复制相似问题