TestMacros.cmake 2.8 KB

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