diff options
Diffstat (limited to 'cmake/tests')
-rw-r--r-- | cmake/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/tests/empty.cpp | 0 | ||||
-rw-r--r-- | cmake/tests/test.cmake | 50 | ||||
-rw-r--r-- | cmake/tests/uic/CMakeLists.txt | 31 | ||||
-rw-r--r-- | cmake/tests/uic/dialog/dialog.ui | 0 | ||||
-rw-r--r-- | cmake/tests/uic/window.ui | 0 |
6 files changed, 82 insertions, 0 deletions
diff --git a/cmake/tests/CMakeLists.txt b/cmake/tests/CMakeLists.txt index 6b53c9703d..dd268bf254 100644 --- a/cmake/tests/CMakeLists.txt +++ b/cmake/tests/CMakeLists.txt @@ -46,3 +46,4 @@ endmacro() add_cmake_test_generate(features) add_cmake_test_generate(qt_make_output_file) +add_cmake_test_generate(uic) diff --git a/cmake/tests/empty.cpp b/cmake/tests/empty.cpp new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/cmake/tests/empty.cpp diff --git a/cmake/tests/test.cmake b/cmake/tests/test.cmake new file mode 100644 index 0000000000..8c11b3a42e --- /dev/null +++ b/cmake/tests/test.cmake @@ -0,0 +1,50 @@ +# FAKE moc-ing: +set(QT_MOCSCANNER /usr/bin/true) + +# Fake mocscanner run. +# The files passed in after MOC will be reported to be in need of moc-ing, +# but will not be built. +# The files passed in after MOC_AND_BUILD will be reported to be in need +# of moc-ing and should also be built by the target. +function(fake_moc_results) + cmake_parse_arguments(arg "" "" "INCLUDED;BUILT") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_included.txt" "${arg_INCLUDED}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_to_build.txt" "${arg_BUILT}") +endfunction() + +# Test whether a target has a file listed in its sources. +# Tests with the BUILD flag set will require this file to be built, +# while those without will require the file to not be built by +# the target. +function(test_source_file target file) + cmake_parse_arguments(arg "BUILD" "" "" ${ARGN}) + + get_target_property(sources "${target}" SOURCES) + list(FIND sources "${file}" source_pos) + assert(NOT source_pos STREQUAL "-1") + + get_source_file_property(prop "${file}" HEADER_FILE_ONLY) + if (arg_BUILD) + assert(NOT prop) + else() + assert(prop) + endif() +endfunction() + +# Test whether or not a target uses a header path +# The test passes when the path is in the list of include directories. +# Passing 'UNKNOWN' to this function reverses the test result. +function(test_include_directory target path) + cmake_parse_arguments(arg "UNKNOWN" "" "" ${ARGN}) + get_target_property(includes "${target}" INCLUDE_DIRECTORIES) + list(FIND includes "${path}" include_pos) + if(arg_UNKNOWN) + assert(include_pos STREQUAL "-1") + else() + assert(NOT include_pos STREQUAL "-1") + endif() +endfunction() + +# Add Core and Qt::Core libraries: +add_library(Core SHARED "${CMAKE_CURRENT_LIST_DIR}/empty.cpp") +add_library(Qt::Core ALIAS Core) diff --git a/cmake/tests/uic/CMakeLists.txt b/cmake/tests/uic/CMakeLists.txt new file mode 100644 index 0000000000..b8455821de --- /dev/null +++ b/cmake/tests/uic/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.12.0) + +project(UicTest + VERSION 1.0.0 + DESCRIPTION "Uic test" + HOMEPAGE_URL "https://qt.io/" + LANGUAGES CXX +) + +## Add some paths to check for cmake modules: +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/extra-cmake-modules/find-modules;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/kwin") + +## Qt specific setup common for all modules: +include(QtSetup) + +include(../test.cmake) + +fake_moc_results() +add_qt_executable(test_executable + SOURCES + ../main.cpp + window.ui +) + +fake_moc_results() +extend_target(test_executable SOURCES dialog/dialog.ui) + +test_source_file(test_executable "${CMAKE_CURRENT_BINARY_DIR}/ui_window.h") +test_source_file(test_executable "${CMAKE_CURRENT_BINARY_DIR}/dialog/ui_dialog.h") + +test_include_directory(test_executable "${CMAKE_CURRENT_BINARY_DIR}/dialog") diff --git a/cmake/tests/uic/dialog/dialog.ui b/cmake/tests/uic/dialog/dialog.ui new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/cmake/tests/uic/dialog/dialog.ui diff --git a/cmake/tests/uic/window.ui b/cmake/tests/uic/window.ui new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/cmake/tests/uic/window.ui |