TestMacros.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Autogen build options
  2. set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}")
  3. if(_isMultiConfig) # Set in Tests/CMakeLists.txt
  4. list(APPEND Autogen_CTEST_OPTIONS --build-config $<CONFIGURATION>)
  5. else()
  6. list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>")
  7. endif()
  8. list(APPEND Autogen_BUILD_OPTIONS
  9. "-DCMAKE_AUTOGEN_VERBOSE=1"
  10. "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
  11. )
  12. # XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion
  13. # when the Xcode generator supports per-config sources.
  14. if(CMAKE_GENERATOR STREQUAL "Xcode")
  15. list(APPEND Autogen_BUILD_OPTIONS -DNO_PER_CONFIG_SOURCES=1)
  16. endif()
  17. # A macro to add a QtAutogen test
  18. macro(ADD_AUTOGEN_TEST NAME)
  19. if(${ARGC} GREATER 1)
  20. # On Windows there is no RPATH, so while Qt might be available for building,
  21. # the required dlls may not be in the PATH, so we can't run the executables
  22. # on that platform.
  23. if(WIN32)
  24. set(_TestCommand --test-command ${CMAKE_CTEST_COMMAND} -V)
  25. else()
  26. set(_TestCommand --test-command ${ARGN})
  27. endif()
  28. endif()
  29. set(_QtXAutogen "Qt${QT_TEST_VERSION}Autogen")
  30. set(_SourceDir "${CMake_SOURCE_DIR}/Tests/QtAutogen/${NAME}")
  31. set(_BuildDir "${CMake_BINARY_DIR}/Tests/${_QtXAutogen}/${NAME}")
  32. add_test(NAME "${_QtXAutogen}.${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}"
  33. --build-and-test
  34. "${_SourceDir}"
  35. "${_BuildDir}"
  36. ${build_generator_args}
  37. --build-project ${NAME}
  38. ${Autogen_CTEST_OPTIONS}
  39. --build-exe-dir "${_BuildDir}"
  40. --force-new-ctest-process
  41. --build-options ${build_options} ${Autogen_BUILD_OPTIONS}
  42. ${_TestCommand}
  43. )
  44. set_tests_properties("${_QtXAutogen}.${NAME}" PROPERTIES LABELS "Qt${QT_TEST_VERSION}")
  45. list(APPEND TEST_BUILD_DIRS "${_BuildDir}")
  46. unset(_TestCommand)
  47. unset(_QtXAutogen)
  48. unset(_SourceDir)
  49. unset(_BuildDir)
  50. endmacro()
  51. # Allow using qtx_wrap_cpp and qtx_generate_moc or not
  52. set(QT_TEST_ALLOW_QT_MACROS TRUE)
  53. # Do a simple check if there is are non ASCII character in the build path
  54. string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR})
  55. if(NON_ASCII_BDIR)
  56. # Qt4 moc does not support utf8 paths in _parameter files generated by
  57. # qtx_wrap_cpp
  58. # https://bugreports.qt.io/browse/QTBUG-35480
  59. if(QT_TEST_VERSION EQUAL 4)
  60. set(QT_TEST_ALLOW_QT_MACROS FALSE)
  61. endif()
  62. # On windows qtx_wrap_cpp also fails in Qt5 when used on a path that
  63. # contains non ASCII characters
  64. if(WIN32)
  65. set(QT_TEST_ALLOW_QT_MACROS FALSE)
  66. endif()
  67. endif()