在构建测试目标后,我有自定义目标来运行我的测试
add_executable( my_unit_test
${SRC}
)
在运行测试之前,我修补了精灵
add_custom_command(
TARGET my_unit_test POST_BUILD
COMMENT "=================== PATCH UNIT TEST ELF ==================="
COMMAND patchelf --set-interpreter /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 my_unit_test
VERBATIM
)
这是运行测试的目标
add_test(
NAME UT
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/my_unit_test
)
add_custom_target( run_ut_tests ALL
DEPENDS my_unit_test
)
add_custom_command( TARGET run_ut_tests POST_BUILD
COMMENT "=================== RUN UNIT TESTS ==================="
COMMAND ctest ARGS --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
问题是测试运行了两次。这里有什么错误?