|
| 1 | +# This file was created the same as fluid/src/controls/CMakeLists.txt in the |
| 2 | +# fluid submodule commit, with a few changes: |
| 3 | +# - rejigger QML module structure (rebased to upstream at https://github.com/lirios/fluid/pull/362) |
| 4 | +# - make the library static |
| 5 | +# - remove an install command |
| 6 | +# - make it work regardless of CMAKE_CURRENT_SOURCE_DIR (i.e. without add_subdirectory) |
| 7 | +# - remove the custom plugin class (controlsplugin.cpp) and use the auto-generated one. Thes |
| 8 | +# custom plugin class registers the image provider, which |
| 9 | +# we no longer use. Using a custom plugin class disables a ton of helpful Qt infrastructure for |
| 10 | +# automatic registration, and with the aggressive linker flags we are using, which don't follow |
| 11 | +# the C++ standard and remove things even from referenced translation units, it's very difficult |
| 12 | +# to get it to stop removing the plugin registration code. |
| 13 | + |
| 14 | +set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fluid/src/controls") |
| 15 | + |
| 16 | +set(LIBNAME Fluid) |
| 17 | + |
| 18 | +# Source files |
| 19 | +set(_sources |
| 20 | + # cpp/controlsplugin.cpp cpp/controlsplugin.h |
| 21 | + cpp/core/clipboard.cpp cpp/core/clipboard.h |
| 22 | + cpp/core/controlsutils.cpp cpp/core/controlsutils.h |
| 23 | + cpp/core/device.cpp cpp/core/device.h |
| 24 | + cpp/core/inputregion.cpp cpp/core/inputregion.h |
| 25 | + cpp/core/standardpaths.cpp cpp/core/standardpaths.h |
| 26 | + cpp/datetime/datepicker.cpp cpp/datetime/datepicker.h |
| 27 | + cpp/datetime/dateselector.cpp cpp/datetime/dateselector.h |
| 28 | + cpp/datetime/datetimepicker.cpp cpp/datetime/datetimepicker.h |
| 29 | + cpp/datetime/dateutils.cpp cpp/datetime/dateutils.h |
| 30 | + cpp/datetime/picker.cpp cpp/datetime/picker.h |
| 31 | + cpp/datetime/timepicker.cpp cpp/datetime/timepicker.h |
| 32 | + cpp/datetime/timeselector.cpp cpp/datetime/timeselector.h |
| 33 | + cpp/datetime/yearmodel.cpp cpp/datetime/yearmodel.h |
| 34 | + cpp/datetime/yearselector.cpp cpp/datetime/yearselector.h |
| 35 | + cpp/iconthemeimageprovider.cpp cpp/iconthemeimageprovider.h |
| 36 | + cpp/style/color.cpp cpp/style/color.h |
| 37 | + cpp/style/style.cpp cpp/style/style.h |
| 38 | +) |
| 39 | + |
| 40 | +# QML files |
| 41 | +file(GLOB_RECURSE _qml CONFIGURE_DEPENDS |
| 42 | + RELATIVE "${SOURCE_DIR}" |
| 43 | + "${SOURCE_DIR}/qml/*.qml" "${SOURCE_DIR}/qml/**/*.qml" |
| 44 | +) |
| 45 | +foreach(_qmlfile ${_qml}) |
| 46 | + set_source_files_properties("${SOURCE_DIR}/${_qmlfile}" PROPERTIES QT_RESOURCE_ALIAS "${_qmlfile}") |
| 47 | +endforeach() |
| 48 | + |
| 49 | +string(REGEX REPLACE cpp/ "${SOURCE_DIR}/cpp/" _sources "${_sources}") |
| 50 | +string(REGEX REPLACE qml/ "${SOURCE_DIR}/qml/" _qml "${_qml}") |
| 51 | + |
| 52 | +# ------------------------------------------------------------ |
| 53 | +# Define the QML module |
| 54 | +# ------------------------------------------------------------ |
| 55 | +set_source_files_properties("${SOURCE_DIR}/qml/core/Units.qml" PROPERTIES |
| 56 | + QT_QML_SINGLETON_TYPE TRUE |
| 57 | +) |
| 58 | + |
| 59 | +qt_add_qml_module(${LIBNAME} STATIC |
| 60 | + URI Fluid |
| 61 | + VERSION 2.0 |
| 62 | + SOURCES ${_sources} |
| 63 | + QML_FILES ${_qml} |
| 64 | + IMPORTS |
| 65 | + QtQuick.Layouts |
| 66 | + DEPENDENCIES |
| 67 | + QtQuick |
| 68 | + QtQuick.Templates |
| 69 | + #Fluid.Private |
| 70 | + PLUGIN_TARGET ${LIBNAME} |
| 71 | + CLASS_NAME FluidPlugin |
| 72 | + NO_PLUGIN_OPTIONAL |
| 73 | +) |
| 74 | + |
| 75 | +set_target_properties(${LIBNAME} PROPERTIES |
| 76 | + AUTOMOC ON |
| 77 | + AUTORCC ON |
| 78 | + AUTOUIC ON |
| 79 | +) |
| 80 | +target_include_directories(${LIBNAME} |
| 81 | + PUBLIC |
| 82 | + ${SOURCE_DIR}/cpp/core |
| 83 | + ${SOURCE_DIR}/cpp/datetime |
| 84 | + ${SOURCE_DIR}/cpp/style |
| 85 | +) |
| 86 | +target_link_libraries(${LIBNAME} |
| 87 | + PRIVATE |
| 88 | + Qt6::Core |
| 89 | + Qt6::Gui |
| 90 | + Qt6::GuiPrivate |
| 91 | + Qt6::Qml |
| 92 | + Qt6::Quick |
| 93 | + Qt6::QuickControls2 |
| 94 | + Qt6::Svg |
| 95 | +) |
| 96 | +target_compile_definitions(${LIBNAME} |
| 97 | + PRIVATE |
| 98 | + FLUID_INSTALL_ICONS=$<IF:$<BOOL:${FLUID_INSTALL_ICONS}>,1,0> |
| 99 | +) |
| 100 | + |
| 101 | +install(TARGETS ${LIBNAME} |
| 102 | + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 103 | + |
| 104 | +# qt_install_qml_module(${LIBNAME}) |
| 105 | + |
| 106 | +if(FLUID_INSTALL_ICONS) |
| 107 | + file(GLOB icons "${SOURCE_DIR}/icons/*/*.svg") |
| 108 | + foreach(source_path IN LISTS icons) |
| 109 | + string(REPLACE "${SOURCE_DIR}/icons/" "" icon_basename "${source_path}") |
| 110 | + get_filename_component(_category "${icon_basename}" DIRECTORY) |
| 111 | + install(FILES "${source_path}" DESTINATION "${QML_INSTALL_DIR}/Fluid/icons/${_category}") |
| 112 | + endforeach() |
| 113 | +else() |
| 114 | + file(GLOB_RECURSE _icons CONFIGURE_DEPENDS |
| 115 | + "${SOURCE_DIR}/icons/*/*.svg" |
| 116 | + ) |
| 117 | + qt_add_resources(${LIBNAME} FluidIcons |
| 118 | + PREFIX "/liri.io/fluid" |
| 119 | + BASE "${SOURCE_DIR}" |
| 120 | + FILES ${_icons} |
| 121 | + ) |
| 122 | +endif() |
0 commit comments