QT_SKIP_DEFAULT_TESTCASE_DIRS

该特性在 Qt 6.9 引入。

注意: This property is in technology preview and may change in future releases.

The property disables the following compile-time definitions for the target:

  • QT_TESTCASE_SOURCEDIR
  • QT_TESTCASE_BUILDDIR

By default, these definitions point to the source and build directories of the target. Since they are only defined for this target, they preclude sharing precompiled headers with the compilation of other targets. If QT_SKIP_DEFAULT_TESTCASE_DIRS 被设为 TRUE these definitions are omitted, avoiding this limitation.

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

The QT_TESTCASE_SOURCEDIR and QT_TESTCASE_BUILDDIR macros will remain undefined when compiling mytest .

The value of the property defaults to the value of the QT_SKIP_DEFAULT_TESTCASE_DIRS 变量。

另请参阅 QFINDTESTDATA and QT_SKIP_DEFAULT_TESTCASE_DIRS .