summaryrefslogtreecommitdiffstats
path: root/examples/sensors/grue/plugin/CMakeLists.txt
blob: 26b5d62459d7b82bd41fa0b940152f1324d70e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

cmake_minimum_required(VERSION 3.16)
project(qtsensors_grue LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)

if(NOT DEFINED INSTALL_EXAMPLESDIR)
    set(INSTALL_EXAMPLESDIR "examples")
endif()

set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/grue/sensors")

find_package(Qt6 REQUIRED COMPONENTS Core Sensors)

qt_add_plugin(qtsensors_grue
    PLUGIN_TYPE sensors
)

target_sources(qtsensors_grue PRIVATE
    gruesensorimpl.cpp gruesensorimpl.h
    gruesensor.cpp gruesensor.h gruesensor_p.h
    main.cpp
)

set_target_properties(qtsensors_grue PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

if(WIN32 OR (UNIX AND NOT APPLE))
    set_target_properties(qtsensors_grue PROPERTIES
        LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../sensors
    )
endif()

if(APPLE AND QT6_IS_SHARED_LIBS_BUILD)
    set_target_properties(qtsensors_grue PROPERTIES
        LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../grue_app.app/Contents/Plugins/sensors
    )
endif()

target_link_libraries(qtsensors_grue PUBLIC
    Qt::Core
    Qt::Sensors
)

if(ANDROID)
    add_custom_target(gruesensorplugin_android_copy ALL
            COMMAND "${CMAKE_COMMAND}"
                -E copy_if_different
                "$<TARGET_FILE:qtsensors_grue>"
                "${CMAKE_CURRENT_BINARY_DIR}/../android-build/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:qtsensors_grue>"
            COMMENT "Copying sensor plugin lib to grue_app android libs folder.")

    add_dependencies(gruesensorplugin_android_copy qtsensors_grue)
endif()

install(TARGETS qtsensors_grue
    RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
    BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
    LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)