CMakeLists.txt 4.03 KB
Newer Older
Eike Hein's avatar
Eike Hein committed
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
cmake_minimum_required(VERSION 3.12)
find_package(ECM 5.54.0 REQUIRED NO_MODULE)
set(CMAKE_CXX_STANDARD 14)
set(CXX_STANDARD_REQUIRED ON)
set(QT_MIN_VERSION "5.12.0")
set(KF5_MIN_VERSION "5.54.0")

project(kirogi VERSION 0.1)

set(CMAKE_AUTOMOC ON)
set(AUTOMOC_MOC_OPTIONS -Muri=org.kde.kirogi)
set(CMAKE_AUTORCC ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(WriteBasicConfigVersionFile)
include(FeatureSummary)
include(ECMGenerateHeaders)
include(ECMAddAppIcon)
include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMQMLModules)
include(ECMQtDeclareLoggingCategory)
include(GNUInstallDirs)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(FindPkgConfig)

option(BUILD_APP "Build the Kirogi application." TRUE)
add_feature_info(BUILD_APP BUILD_APP "Build the Kirogi application.")

option(BUILD_QT_QUICK_LIB "Build the Kirogi library with Qt Quick support." TRUE)
add_feature_info(BUILD_QT_QUICK_LIB BUILD_QT_QUICK_LIB "Build the Kirogi library with Qt Quick support.")

option(BUILD_PLUGINS "Build the Kirogi plugins." TRUE)
add_feature_info(BUILD_PLUGINS BUILD_PLUGINS "Build the Kirogi plugins.")

option(COMPILE_QML "Pre-compile QML files using the Qt Quick compiler." FALSE)
add_feature_info(COMPILE_QML COMPILE_QML "Pre-compile QML files using the Qt Quick compiler.")

if (BUILD_APP)
    if(NOT ANDROID)
        set(qtDesktopComponents "Widgets")
        set(kfDesktopComponents
            "Crash"
            "DNSSD"
        )
    else()
        # The Material style requires QtSvg.
        set(qtAndroidComponents
            "AndroidExtras"
            "Svg"
        )
    endif()

    ecm_find_qmlmodule(QtGamePad 5.12)
    ecm_find_qmlmodule(QtGraphicalEffects 1.12)
    ecm_find_qmlmodule(QtLocation 5.12)
    ecm_find_qmlmodule(org.kde.kirigami 2.6)
64 65 66 67 68 69

    # FIXME TODO: QtGamepad currently causes performance problems on
    # Android (blocking multi-tasking) that need to be investigated.
    if(NOT ANDROID)
        ecm_find_qmlmodule(QtPositioning 5.12)
    endif()
Eike Hein's avatar
Eike Hein committed
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
endif()

if(BUILD_APP OR BUILD_QT_QUICK_LIB)
    set(qtQuickComponents
        "Qml"
        "Quick"
    )
endif()

find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
    Core
    Gamepad
    Network
    Positioning
    ${qtQuickComponents}
    ${qtDesktopComponents}
    ${qtAndroidComponents}
)

find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
    ConfigWidgets
    CoreAddons
    I18n
    Kirigami2
    ${kfDesktopComponents}
)

find_package(PkgConfig REQUIRED)

pkg_check_modules(GSTREAMER REQUIRED
    gstreamer-1.0
    gstreamer-video-1.0
)

link_directories(${GSTREAMER_LIBRARY_DIRS})
include_directories (${GSTREAMER_INCLUDE_DIRS})

if(ANDROID)
    pkg_check_modules(GSTREAMER REQUIRED
        gstreamer-1.0
        gstreamer-audio-1.0
        gstreamer-codecparsers-1.0
        gstreamer-controller-1.0
        gstreamer-gl-1.0
        gstreamer-net-1.0
        gstreamer-pbutils-1.0
        gstreamer-rtp-1.0
        gstreamer-tag-1.0
        gstreamer-video-1.0
        gio-2.0
        graphene-1.0
        libjpeg
        libpng16
        libavformat
        libavcodec
        libavfilter
        libavutil
        libswresample
        x264
    )

    link_directories(${GSTREAMER_LIBRARY_DIRS}/gstreamer-1.0/)
endif()

if(COMPILE_QML)
    find_package(Qt5QuickCompiler)

    set_package_properties(Qt5QuickCompiler PROPERTIES
        DESCRIPTION "Pre-compile QML files using the Qt Quick compiler."
        TYPE OPTIONAL
    )
endif()

add_definitions(
  -DQT_USE_QSTRINGBUILDER
  -DQT_NO_CAST_TO_ASCII
  -DQT_STRICT_ITERATORS
  -DQT_NO_URL_CAST_FROM_STRING
  -DQT_NO_CAST_FROM_BYTEARRAY
  -DQT_NO_SIGNALS_SLOTS_KEYWORDS
  -DQT_USE_FAST_OPERATOR_PLUS
)

# For KConfigXT out-of-source builds.
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_subdirectory(data)
add_subdirectory(src)

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)