diff options
9 files changed, 282 insertions, 13 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index c901169735..d74a38f51a 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -1037,11 +1037,13 @@ extend_target(Core CONDITION QT_FEATURE_mimetype ) # Resources: -set_source_files_properties("mimetypes/mime/packages/freedesktop.org.xml" - PROPERTIES alias "freedesktop.org.xml") -add_qt_resource(Core "mimetypes" PREFIX "/qt-project.org/qmime/packages" BASE "mimetypes" FILES - mime/packages/freedesktop.org.xml) - +# special case begin +# We can't specify the resources directly as we have unit tests that +# depend on these as well and we no longer support the use of hand +# edited qrc files. +include(${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mimetypes_resources.cmake) +corelib_add_mimetypes_resources(Core) +# special case end extend_target(Core CONDITION WASM SOURCES diff --git a/src/corelib/mimetypes/mimetypes_resources.cmake b/src/corelib/mimetypes/mimetypes_resources.cmake new file mode 100644 index 0000000000..42454beb87 --- /dev/null +++ b/src/corelib/mimetypes/mimetypes_resources.cmake @@ -0,0 +1,21 @@ +# List of files that need to be packaged as resources. +# This file exists solely because of unit tests that need access to this +# information as well. This was previosly handled by referrencing a qrc +# file with the same information + +set(corelib_mimetypes_resource_file + "${CMAKE_CURRENT_LIST_DIR}/mime/packages/freedesktop.org.xml" +) + +function(corelib_add_mimetypes_resources target) + set(source_file "${corelib_mimetypes_resource_file}") + set_source_files_properties("${source_file}" + PROPERTIES alias "freedesktop.org.xml" + ) + add_qt_resource(${target} "mimetypes" + PREFIX + "/qt-project.org/qmime/packages" + FILES + "${source_file}" + ) +endfunction() diff --git a/tests/auto/corelib/mimetypes/CMakeLists.txt b/tests/auto/corelib/mimetypes/CMakeLists.txt index 1e59aa3329..ea0463de36 100644 --- a/tests/auto/corelib/mimetypes/CMakeLists.txt +++ b/tests/auto/corelib/mimetypes/CMakeLists.txt @@ -1,2 +1,14 @@ -# add_subdirectory(qmimetype) +# Generated from mimetypes.pro. +# special case begin +if(FEATURE_private_tests) +# special case end + add_subdirectory(qmimetype) + add_subdirectory(qmimedatabase) +# special case begin +endif() +# special case end + +if(NOT QT_FEATURE_private_tests) + ### remove_subdirectory("qmimetype") +endif() diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/CMakeLists.txt new file mode 100644 index 0000000000..6661952a68 --- /dev/null +++ b/tests/auto/corelib/mimetypes/qmimedatabase/CMakeLists.txt @@ -0,0 +1,10 @@ +# Generated from qmimedatabase.pro. + + +if(TARGET Qt::Concurrent) + add_subdirectory(qmimedatabase-xml) + + if(UNIX AND NOT APPLE AND NOT QNX) + add_subdirectory(qmimedatabase-cache) + endif() +endif() diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/.prev_CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/.prev_CMakeLists.txt new file mode 100644 index 0000000000..4a3d150123 --- /dev/null +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/.prev_CMakeLists.txt @@ -0,0 +1,66 @@ +# Generated from qmimedatabase-cache.pro. + +##################################################################### +## tst_qmimedatabase-cache Test: +##################################################################### + +add_qt_test(tst_qmimedatabase-cache + SOURCES + ../tst_qmimedatabase.h + tst_qmimedatabase-cache.cpp + PUBLIC_LIBRARIES + Qt::Concurrent +) + +# Resources: +set_source_files_properties("../qml-again.xml" + PROPERTIES alias "qml-again.xml"] +) +set_source_files_properties("../test.qml" + PROPERTIES alias "test.qml"] +) +set_source_files_properties("../text-x-objcsrc.xml" + PROPERTIES alias "text-x-objcsrc.xml"] +) +set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml" + PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml"] +) +add_qt_resource(tst_qmimedatabase-cache "testdata" + PREFIX + "/qt-project.org/qmime" + BASE + ".." + FILES + invalid-magic1.xml + invalid-magic2.xml + invalid-magic3.xml + magic-and-hierarchy.foo + magic-and-hierarchy.xml + magic-and-hierarchy2.foo + qml-again.xml + test.qml + text-x-objcsrc.xml + yast2-metapackage-handler-mimetypes.xml +) + + +#### Keys ignored in scope 1:.:.:qmimedatabase-cache.pro:<TRUE>: +# CONFIG = "testcase" + +## Scopes: +##################################################################### + +extend_target(tst_qmimedatabase-cache CONDITION 2*_x_ - g + COMPILE_OPTIONS + -W + -Wall + -Wextra + -Wno-long-long + -Wnon-virtual-dtor + -Wshadow +) + +extend_target(tst_qmimedatabase-cache CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX + DEFINES + USE_XDG_DATA_DIRS +) diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt new file mode 100644 index 0000000000..c7e3f9613d --- /dev/null +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/CMakeLists.txt @@ -0,0 +1,72 @@ +# Generated from qmimedatabase-cache.pro. + +##################################################################### +## tst_qmimedatabase-cache Test: +##################################################################### + +add_qt_test(tst_qmimedatabase-cache + SOURCES + ../tst_qmimedatabase.h + tst_qmimedatabase-cache.cpp + PUBLIC_LIBRARIES + Qt::Concurrent +) + +# Resources: +set_source_files_properties("../qml-again.xml" + PROPERTIES alias "qml-again.xml" +) +set_source_files_properties("../test.qml" + PROPERTIES alias "test.qml" +) +set_source_files_properties("../text-x-objcsrc.xml" + PROPERTIES alias "text-x-objcsrc.xml" +) +set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml" + PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml" +) +add_qt_resource(tst_qmimedatabase-cache "testdata" + PREFIX + "/qt-project.org/qmime" + BASE + ".." + FILES + invalid-magic1.xml + invalid-magic2.xml + invalid-magic3.xml + magic-and-hierarchy.foo + magic-and-hierarchy.xml + magic-and-hierarchy2.foo + qml-again.xml + test.qml + text-x-objcsrc.xml + yast2-metapackage-handler-mimetypes.xml +) + +# special case begin +set(corelib_source_dir ../../../../../../src/corelib) +include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake) +corelib_add_mimetypes_resources(tst_qmimedatabase-cache) +# special case end + +#### Keys ignored in scope 1:.:.:qmimedatabase-cache.pro:<TRUE>: +# CONFIG = "testcase" + +## Scopes: +##################################################################### + +extend_target(tst_qmimedatabase-cache CONDITION CMAKE_COMPILER_IS_GNUCXX + + COMPILE_OPTIONS + -W + -Wall + -Wextra + -Wno-long-long + -Wnon-virtual-dtor + -Wshadow +) + +extend_target(tst_qmimedatabase-cache CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX + DEFINES + USE_XDG_DATA_DIRS +) diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt new file mode 100644 index 0000000000..526b63aafa --- /dev/null +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/CMakeLists.txt @@ -0,0 +1,72 @@ +# Generated from qmimedatabase-xml.pro. + +##################################################################### +## tst_qmimedatabase-xml Test: +##################################################################### + +add_qt_test(tst_qmimedatabase-xml + SOURCES + ../tst_qmimedatabase.h + tst_qmimedatabase-xml.cpp + PUBLIC_LIBRARIES + Qt::ConcurrentPrivate +) + +# Resources: +set_source_files_properties("../qml-again.xml" + PROPERTIES alias "qml-again.xml" +) +set_source_files_properties("../test.qml" + PROPERTIES alias "test.qml" +) +set_source_files_properties("../text-x-objcsrc.xml" + PROPERTIES alias "text-x-objcsrc.xml" +) +set_source_files_properties("../yast2-metapackage-handler-mimetypes.xml" + PROPERTIES alias "yast2-metapackage-handler-mimetypes.xml" +) + +add_qt_resource(tst_qmimedatabase-xml "testdata" + PREFIX + "/qt-project.org/qmime" + BASE + ".." + FILES + invalid-magic1.xml + invalid-magic2.xml + invalid-magic3.xml + magic-and-hierarchy.foo + magic-and-hierarchy.xml + magic-and-hierarchy2.foo + qml-again.xml + test.qml + text-x-objcsrc.xml + yast2-metapackage-handler-mimetypes.xml +) + +# special case begin +set(corelib_source_dir ../../../../../../src/corelib) +include(${corelib_source_dir}/mimetypes/mimetypes_resources.cmake) +corelib_add_mimetypes_resources(tst_qmimedatabase-xml) +# special case end + +#### Keys ignored in scope 1:.:.:qmimedatabase-xml.pro:<TRUE>: +# CONFIG = "testcase" + +## Scopes: +##################################################################### + +extend_target(tst_qmimedatabase-xml CONDITION CMAKE_COMPILER_IS_GNUCXX + COMPILE_OPTIONS + -W + -Wall + -Wextra + -Wno-long-long + -Wnon-virtual-dtor + -Wshadow +) + +extend_target(tst_qmimedatabase-xml CONDITION UNIX AND NOT APPLE_OSX AND NOT QNX + DEFINES + USE_XDG_DATA_DIRS +) diff --git a/tests/auto/corelib/mimetypes/qmimetype/CMakeLists.txt b/tests/auto/corelib/mimetypes/qmimetype/CMakeLists.txt index 9b70d0971a..adfcefb917 100644 --- a/tests/auto/corelib/mimetypes/qmimetype/CMakeLists.txt +++ b/tests/auto/corelib/mimetypes/qmimetype/CMakeLists.txt @@ -1 +1,15 @@ -add_qt_test(tst_qmimetype SOURCES tst_qmimetype.cpp LIBRARIES Qt::CorePrivate) +# Generated from qmimetype.pro. + +##################################################################### +## tst_qmimetype Test: +##################################################################### + +add_qt_test(tst_qmimetype + SOURCES + tst_qmimetype.cpp + LIBRARIES + Qt::CorePrivate +) + +#### Keys ignored in scope 1:.:.:qmimetype.pro:<TRUE>: +# CONFIG = "testcase" diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 22b2d03219..5003faa370 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -132,18 +132,18 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '') -> str: if alias: full_source = os.path.join(base_dir, source) output += 'set_source_files_properties("{}"\n' \ - ' PROPERTIES alias "{}")\n'.format(full_source, alias) + ' PROPERTIES alias "{}"\n)\n'.format(full_source, alias) params = '' if lang: - params += ' LANG "{}"'.format(lang) + params += ' LANG\n "{}"\n'.format(lang) if prefix: - params += ' PREFIX "{}"'.format(prefix) + params += ' PREFIX\n "{}"\n'.format(prefix) if base_dir: - params += ' BASE "{}"'.format(base_dir) - output += 'add_qt_resource({} "{}"{} FILES\n {})\n'.format(target, full_resource_name, + params += ' BASE\n "{}"\n'.format(base_dir) + output += 'add_qt_resource({} "{}"\n{} FILES\n {}\n)\n'.format(target, full_resource_name, params, - '\n '.join(sorted_files)) + '\n '.join(sorted_files)) resource_count += 1 |