Using REQUIRED_FILES for unit tests in cmake
问题 Very short example trying to use REQUIRED_FILES: $ tree . . ├── CMakeLists.txt └── main.cxx $ cat main.cxx int main() { return 0; } $ cat CMakeLists.txt cmake_minimum_required(VERSION 3.10) add_executable(a.out main.cxx) include(CTest) add_test(NAME a.out COMMAND a.out) set_property(TEST a.out PROPERTY REQUIRED_FILES $<TARGET_FILE:a.out>) One executable, which does nothing, and is a test that just requires itself to exist. $ mkdir build && cd build && cmake .. && ctest -- The C compiler