TestMacros.cmake 2.1 KB

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