QT_SKIP_DEFAULT_TESTCASE_DIRS

该属性自 Qt 6.9 起引入。

注意:该 属性目前处于技术预览阶段,未来版本中可能会发生变化。

该属性会禁用目标的以下编译时定义:

  • QT_TESTCASE_SOURCEDIR
  • QT_TESTCASE_BUILDDIR

默认情况下,这些定义指向目标的源代码目录和构建目录。由于它们仅针对该目标定义,因此会阻止与其他目标的编译共享预编译头文件。如果将QT_SKIP_DEFAULT_TESTCASE_DIRS 设置为TRUE ,则会省略这些定义,从而避免此限制。

qt_add_executable(mytest main.cpp)
set_property(TARGET mytest PROPERTY QT_SKIP_DEFAULT_TESTCASE_DIRS TRUE)
target_link_libraries(mytest PRIVATE Qt6::Test)

在编译mytest 时,QT_TESTCASE_SOURCEDIR 和QT_TESTCASE_BUILDDIR 宏将保持未定义状态。

该属性的默认值即为QT_SKIP_DEFAULT_TESTCASE_DIRS变量的值。

另请参阅 QFINDTESTDATA 和QT_SKIP_DEFAULT_TESTCASE_DIRS。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.