From 4483c3f31e0e07a2ac15b28d8ec02b84152c1656 Mon Sep 17 00:00:00 2001 From: Mateusz Fibor Date: Tue, 7 Jan 2025 20:45:18 +0100 Subject: [PATCH] chore: Add QML demo app as subdir of QtScrcpy Also take into account Qt builds which arent built with X11 support in xmousetap.cpp --- CMakeLists.txt | 3 +-- QtScrcpy/CMakeLists.txt | 13 ++++++++++++- {TestQml => QtScrcpy/TestQml}/CMakeLists.txt | 14 ++------------ {TestQml => QtScrcpy/TestQml}/Main.qml | 0 {TestQml => QtScrcpy/TestQml}/main.cpp | 0 QtScrcpy/util/mousetap/xmousetap.cpp | 5 +++++ 6 files changed, 20 insertions(+), 15 deletions(-) rename {TestQml => QtScrcpy/TestQml}/CMakeLists.txt (68%) rename {TestQml => QtScrcpy/TestQml}/Main.qml (100%) rename {TestQml => QtScrcpy/TestQml}/main.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d97c96e..ba0c4a65 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.19 FATAL_ERROR) project(all) -add_subdirectory(QtScrcpy) -add_subdirectory(TestQml) +add_subdirectory(QtScrcpy) \ No newline at end of file diff --git a/QtScrcpy/CMakeLists.txt b/QtScrcpy/CMakeLists.txt index f33160f7..5de75a17 100755 --- a/QtScrcpy/CMakeLists.txt +++ b/QtScrcpy/CMakeLists.txt @@ -18,6 +18,8 @@ set(QC_PROJECT_VERSION ${QC_FILE_VERSION}) project(${QC_PROJECT_NAME} VERSION ${QC_PROJECT_VERSION} LANGUAGES CXX) message(STATUS "[${PROJECT_NAME}] Project ${PROJECT_NAME} ${PROJECT_VERSION}") +option(BUILD_QML_DEMO "Build demo QML app" ON) + # QC define # check arch @@ -68,7 +70,12 @@ if (NOT MSVC) add_compile_options(-Wall -Wextra -pedantic -Werror) # disable some warning - add_compile_options(-Wno-nested-anon-types -Wno-c++17-extensions -Wno-overloaded-virtual) + set(QSC_COMPILE_DEFINITIONS -Wno-nested-anon-types -Wno-c++17-extensions -Wno-overloaded-virtual) + if(BUILD_QML_DEMO) + set(QSC_COMPILE_DEFINITIONS ${QSC_COMPILE_DEFINITIONS} -Wno-gnu-zero-variadic-macro-arguments) + endif() + + add_compile_options(${QSC_COMPILE_DEFINITIONS}) endif() # @@ -359,3 +366,7 @@ target_link_libraries(QtScrcpyQml PRIVATE Qt${QT_VERSION_MAJOR}::Quick QtScrcpyCore ) + +if(BUILD_QML_DEMO) + add_subdirectory(TestQml) +endif() diff --git a/TestQml/CMakeLists.txt b/QtScrcpy/TestQml/CMakeLists.txt similarity index 68% rename from TestQml/CMakeLists.txt rename to QtScrcpy/TestQml/CMakeLists.txt index 749dbaa1..0bb8cc32 100644 --- a/TestQml/CMakeLists.txt +++ b/QtScrcpy/TestQml/CMakeLists.txt @@ -1,13 +1,3 @@ -cmake_minimum_required(VERSION 3.16) - -project(TestQml VERSION 0.1 LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -find_package(Qt6 REQUIRED COMPONENTS Quick) - -qt_standard_project_setup(REQUIRES 6.5) - qt_add_executable(appTestQml main.cpp ) @@ -48,9 +38,9 @@ else() endif() set_target_properties(appTestQml PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../output/${QC_CPU_ARCH}/${CMAKE_BUILD_TYPE}/$<0:>" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../output/${QC_CPU_ARCH}/${CMAKE_BUILD_TYPE}/$<0:>" ) add_custom_command(TARGET appTestQml POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/config/config.ini" "${CMAKE_CURRENT_SOURCE_DIR}/../output/${QC_CPU_ARCH}/${CMAKE_BUILD_TYPE}/config/config.ini" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../../config/config.ini" "${CMAKE_CURRENT_SOURCE_DIR}/../../output/${QC_CPU_ARCH}/${CMAKE_BUILD_TYPE}/config/config.ini" ) diff --git a/TestQml/Main.qml b/QtScrcpy/TestQml/Main.qml similarity index 100% rename from TestQml/Main.qml rename to QtScrcpy/TestQml/Main.qml diff --git a/TestQml/main.cpp b/QtScrcpy/TestQml/main.cpp similarity index 100% rename from TestQml/main.cpp rename to QtScrcpy/TestQml/main.cpp diff --git a/QtScrcpy/util/mousetap/xmousetap.cpp b/QtScrcpy/util/mousetap/xmousetap.cpp index a5fa5610..a455f166 100644 --- a/QtScrcpy/util/mousetap/xmousetap.cpp +++ b/QtScrcpy/util/mousetap/xmousetap.cpp @@ -23,6 +23,7 @@ void XMouseTap::initMouseEventTap() {} void XMouseTap::quitMouseEventTap() {} void XMouseTap::enableMouseEventTap(QRect rc, bool enabled) { +#if QT_FEATURE_xcb==1 if (enabled && rc.isEmpty()) { return; } @@ -61,4 +62,8 @@ void XMouseTap::enableMouseEventTap(QRect rc, bool enabled) { XUngrabPointer(display, CurrentTime); } XFlush(display); +#else + Q_UNUSED(rc); + Q_UNUSED(enabled); +#endif }