summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen/TestMacros.cmake
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-12-08 16:09:30 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-12-13 12:48:27 (GMT)
commit227a7974f426e0966d1736c66dd606b068985d1b (patch)
tree1b0048d6c54e4c0d88c1313bc6bc30c3f0c18610 /Tests/QtAutogen/TestMacros.cmake
parentbd10c3cf82f6e9d58b121498eaa2b9d8cc19dd2f (diff)
downloadCMake-227a7974f426e0966d1736c66dd606b068985d1b.zip
CMake-227a7974f426e0966d1736c66dd606b068985d1b.tar.gz
CMake-227a7974f426e0966d1736c66dd606b068985d1b.tar.bz2
Autogen: Tests: Add basic scripts for separate tests
Diffstat (limited to 'Tests/QtAutogen/TestMacros.cmake')
-rw-r--r--Tests/QtAutogen/TestMacros.cmake61
1 files changed, 61 insertions, 0 deletions
diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake
new file mode 100644
index 0000000..849a733
--- /dev/null
+++ b/Tests/QtAutogen/TestMacros.cmake
@@ -0,0 +1,61 @@
+# Autogen build options
+set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}")
+if(NOT CMAKE_CONFIGURATION_TYPES)
+ list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>")
+endif()
+list(APPEND Autogen_BUILD_OPTIONS
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+)
+
+# A macro to add a QtAutogen test
+macro(ADD_AUTOGEN_TEST NAME)
+ if(${ARGC} GREATER 1)
+ # On Windows there is no RPATH, so while Qt might be available for building,
+ # the required dlls may not be in the PATH, so we can't run the executables
+ # on that platform.
+ if(WIN32)
+ set(_TestCommand --test-command ${CMAKE_CTEST_COMMAND} -V)
+ else()
+ set(_TestCommand --test-command ${ARGN})
+ endif()
+ endif()
+
+ set(_QtXAutogen "Qt${QT_TEST_VERSION}Autogen")
+ set(_SourceDir "${CMake_SOURCE_DIR}/Tests/QtAutogen/${NAME}")
+ set(_BuildDir "${CMake_BINARY_DIR}/Tests/${_QtXAutogen}/${NAME}")
+ add_test(NAME "${_QtXAutogen}.${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}"
+ --build-and-test
+ "${_SourceDir}"
+ "${_BuildDir}"
+ ${build_generator_args}
+ --build-project ${NAME}
+ --build-exe-dir "${_BuildDir}"
+ --force-new-ctest-process
+ --build-options ${build_options} ${Autogen_BUILD_OPTIONS}
+ ${_TestCommand}
+ )
+ list(APPEND TEST_BUILD_DIRS "${_BuildDir}")
+ unset(_TestCommand)
+ unset(_QtXAutogen)
+ unset(_SourceDir)
+ unset(_BuildDir)
+endmacro()
+
+
+# Allow using qtx_wrap_cpp and qtx_generate_moc or not
+set(ALLOW_WRAP_CPP TRUE)
+# Do a simple check if there is are non ASCII character in the build path
+string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR})
+if(NON_ASCII_BDIR)
+ # Qt4 moc does not support utf8 paths in _parameter files generated by
+ # qtx_wrap_cpp
+ # https://bugreports.qt.io/browse/QTBUG-35480
+ if(QT_TEST_VERSION STREQUAL 4)
+ set(ALLOW_WRAP_CPP FALSE)
+ endif()
+ # On windows qtx_wrap_cpp also fails in Qt5 when used on a path that
+ # contains non ASCII characters
+ if(WIN32)
+ set(ALLOW_WRAP_CPP FALSE)
+ endif()
+endif()