TestMacros.cmake 2.1 KB

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