summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate-game/CMakeLists.txt
blob: 4640196446687c740f54661e9d18e5cbb36f9299 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.16)
project(heartrate-game LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

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

set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/bluetooth/heartrate-game")

find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Bluetooth)

qt_add_executable(heartrate-game
    bluetoothbaseclass.cpp bluetoothbaseclass.h
    connectionhandler.cpp connectionhandler.h
    devicefinder.cpp devicefinder.h
    devicehandler.cpp devicehandler.h
    deviceinfo.cpp deviceinfo.h
    heartrate-global.h
    main.cpp
)
set_target_properties(heartrate-game PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)
target_link_libraries(heartrate-game PUBLIC
    Qt::Bluetooth
    Qt::Core
    Qt::Gui
    Qt::Qml
    Qt::Quick
)

if (APPLE)
    if (IOS)
        set_target_properties(heartrate-game PROPERTIES
            MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
        )
    else()
        # Using absolute path for shared plist files is a Ninja bug workaround
        get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE)
        set_target_properties(heartrate-game PROPERTIES
            MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist"
        )
    endif()
endif()

# Resources:
set(qml_resource_files
    "qml/App.qml"
    "qml/BluetoothAlarmDialog.qml"
    "qml/BottomLine.qml"
    "qml/Connect.qml"
    "qml/GameButton.qml"
    "qml/GamePage.qml"
    "qml/GameSettings.qml"
    "qml/Measure.qml"
    "qml/SplashScreen.qml"
    "qml/Stats.qml"
    "qml/StatsLabel.qml"
    "qml/TitleBar.qml"
    "qml/main.qml"
    "qml/qmldir"
)

qt6_add_resources(heartrate-game "qml"
    PREFIX
        "/"
    FILES
        ${qml_resource_files}
)
set(images_resource_files
    "qml/images/bt_off_to_on.png"
    "qml/images/heart.png"
    "qml/images/logo.png"
)

qt6_add_resources(heartrate-game "images"
    PREFIX
        "/"
    FILES
        ${images_resource_files}
)

install(TARGETS heartrate-game
    RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
    BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
    LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)