TestMacros.cmake 2.0 KB

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