summaryrefslogtreecommitdiffstats
path: root/examples/sensors/grue/CMakeLists.txt
blob: 55e234ce6fe7ce9944f03cfe2531db22a55c6e3f (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
65
66
67
68
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

cmake_minimum_required(VERSION 3.16)
project(grue_app LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)

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

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

find_package(Qt6 REQUIRED COMPONENTS Quick Sensors)

qt_add_executable(grue_app
    main.cpp qmlgruesensor.h qmlgruesensor.cpp
)

set_target_properties(grue_app PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

target_link_libraries(grue_app PUBLIC
    Qt::Quick
    Qt::Sensors
)

qt6_add_qml_module(grue_app
    VERSION 1.0
    URI "QMLGrueSensor"
    QML_FILES
        grue.qml
    RESOURCES
        grue.png
)

add_subdirectory(plugin)

# Need to link to the plugin manually in a static Qt build.
if(NOT QT6_IS_SHARED_LIBS_BUILD)
    target_link_libraries(grue_app PRIVATE qtsensors_grue)
    target_sources(grue_app PRIVATE grue_plugin_import_custom.cpp)
endif()

set(build_console_app TRUE)

# The console app is not a macos bundle, so the shared library plugin wouldn't be found
if(APPLE AND QT6_IS_SHARED_LIBS_BUILD)
    set(build_console_app FALSE)
endif()

# Gui-less apps don't make sense for these platforms
if(IOS OR EMSCRIPTEN OR ANDROID)
    set(build_console_app FALSE)
endif()

if(build_console_app)
    add_subdirectory(console_app)
endif()

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