summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-04-20 09:09:59 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-04-20 12:17:05 +0300
commit84cd882daf1afab59596f2f27db5aad5ce9b8f6b (patch)
treef3fbcbe393381bd89237987c32d1f21cf8969296
parent45c8ae3232df8955644697ee88c4321f26bb5cf2 (diff)
Compile-config test for winrt
While winrt as a "windows phone" is not supported anymore, the APIs are available on windows and can be supported where applicable (bluetooth, positioning, sensors, ...). This commit adds a configuration tests for the presence of these headers and libraries. Task-number: QTBUG-92502 Change-Id: Ia6dcb0a6b8ecdbcf1d1bcf79e42f95ace75f6657 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--config.tests/winrt/CMakeLists.txt27
-rw-r--r--config.tests/winrt/main.cpp51
-rw-r--r--src/plugins/sensors/CMakeLists.txt2
-rw-r--r--src/plugins/sensors/winrt/CMakeLists.txt6
-rw-r--r--src/sensors/configure.cmake16
5 files changed, 99 insertions, 3 deletions
diff --git a/config.tests/winrt/CMakeLists.txt b/config.tests/winrt/CMakeLists.txt
new file mode 100644
index 00000000..998d8cad
--- /dev/null
+++ b/config.tests/winrt/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.14.0)
+project(config_test_winrt LANGUAGES C CXX)
+
+foreach(p ${QT_CONFIG_COMPILE_TEST_PACKAGES})
+ find_package(${p})
+endforeach()
+
+if(QT_CONFIG_COMPILE_TEST_LIBRARIES)
+ link_libraries(${QT_CONFIG_COMPILE_TEST_LIBRARIES})
+endif()
+if(QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS)
+ foreach(lib ${QT_CONFIG_COMPILE_TEST_LIBRARY_TARGETS})
+ if(TARGET ${lib})
+ link_libraries(${lib})
+ endif()
+ endforeach()
+endif()
+
+add_executable(${PROJECT_NAME}
+ main.cpp
+)
+
+if(MSVC)
+ target_link_libraries(${PROJECT_NAME} PRIVATE
+ runtimeobject.lib
+ )
+endif()
diff --git a/config.tests/winrt/main.cpp b/config.tests/winrt/main.cpp
new file mode 100644
index 00000000..8bcec2f4
--- /dev/null
+++ b/config.tests/winrt/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <functional>
+#include <windows.system.h>
+
+#include <windows.devices.sensors.h>
+#include <windows.foundation.h>
+#include <wrl.h>
+
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+using namespace ABI::Windows::Foundation;
+using namespace ABI::Windows::Devices::Sensors;
+
+typedef ITypedEventHandler<Accelerometer *, AccelerometerReadingChangedEventArgs *> AccelerometerReadingHandler;
+
+int main(int, char**)
+{
+ HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Accelerometer);
+ ComPtr<IAccelerometer> sensor;
+ ComPtr<IAccelerometerStatics> factory;
+ HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory));
+ hr = factory->GetDefault(&sensor);
+ return 0;
+}
diff --git a/src/plugins/sensors/CMakeLists.txt b/src/plugins/sensors/CMakeLists.txt
index 08bfa26a..7b0644c4 100644
--- a/src/plugins/sensors/CMakeLists.txt
+++ b/src/plugins/sensors/CMakeLists.txt
@@ -10,7 +10,7 @@ endif()
# add_subdirectory(sensorfw)
#endif()
-if (WIN32 AND NOT SENSORS_PLUGINS OR "winrt" IN_LIST SENSORS_PLUGINS)
+if (QT_FEATURE_winrt_sensors AND NOT SENSORS_PLUGINS OR "winrt" IN_LIST SENSORS_PLUGINS)
add_subdirectory(winrt)
endif()
diff --git a/src/plugins/sensors/winrt/CMakeLists.txt b/src/plugins/sensors/winrt/CMakeLists.txt
index 2099547e..cd8191e8 100644
--- a/src/plugins/sensors/winrt/CMakeLists.txt
+++ b/src/plugins/sensors/winrt/CMakeLists.txt
@@ -19,7 +19,11 @@ qt_internal_add_plugin(WinRtSensorPlugin
Qt::Sensors
LIBRARIES
Qt::CorePrivate
- runtimeobject
+)
+
+qt_internal_extend_target(WinRtSensorPlugin CONDITION MSVC
+ PUBLIC_LIBRARIES
+ runtimeobject.lib
)
#### Keys ignored in scope 1:.:.:winrt.pro:<TRUE>:
diff --git a/src/sensors/configure.cmake b/src/sensors/configure.cmake
index 06e0de59..7779bf09 100644
--- a/src/sensors/configure.cmake
+++ b/src/sensors/configure.cmake
@@ -13,7 +13,11 @@ endif()
#### Tests
-
+if (WIN32 AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../config.tests/winrt/CMakeLists.txt")
+ qt_config_compile_test("winrt_sensors"
+ LABEL "WinRT sensors"
+ PROJECT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../config.tests/winrt")
+endif()
#### Features
@@ -24,6 +28,11 @@ qt_feature("sensorfw" PRIVATE
)
# special case end
+qt_feature("winrt_sensors" PRIVATE
+ LABEL "WinRT sensors backend"
+ CONDITION WIN32 AND TEST_winrt_sensors
+)
+
qt_configure_add_summary_section(NAME "Qt Sensors")
if (LINUX)
# At the moment there is no Qt6 version of sensorfw, and while the
@@ -35,4 +44,9 @@ if (LINUX)
qt_configure_add_summary_entry(ARGS "sensorfw_enabled_with_cmake")
qt_configure_add_report(MESSAGE "SensorFW support currently not enabled with cmake")
endif()
+
+if (WIN32)
+ qt_configure_add_summary_entry(ARGS "winrt_sensors")
+endif()
+
qt_configure_end_summary_section() # end of "Qt Sensors" section