1# This file controls Flutter-level build steps. It should not be edited. 2cmake_minimum_required(VERSION 3.10) 3 4set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 6# Configuration provided via flutter tool. 7include(${EPHEMERAL_DIR}/generated_config.cmake) 8 9# TODO: Move the rest of this into files in ephemeral. See 10# https://github.com/flutter/flutter/issues/57146. 11 12# Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13# which isn't available in 3.10. 14function(list_prepend LIST_NAME PREFIX) 15 set(NEW_LIST "") 16 foreach(element ${${LIST_NAME}}) 17 list(APPEND NEW_LIST "${PREFIX}${element}") 18 endforeach(element) 19 set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20endfunction() 21 22# === Flutter Library === 23# System-level dependencies. 24find_package(PkgConfig REQUIRED) 25pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 29set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 31# Published to parent scope for install step. 32set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 37list(APPEND FLUTTER_LIBRARY_HEADERS 38 "fl_basic_message_channel.h" 39 "fl_binary_codec.h" 40 "fl_binary_messenger.h" 41 "fl_dart_project.h" 42 "fl_engine.h" 43 "fl_json_message_codec.h" 44 "fl_json_method_codec.h" 45 "fl_message_codec.h" 46 "fl_method_call.h" 47 "fl_method_channel.h" 48 "fl_method_codec.h" 49 "fl_method_response.h" 50 "fl_plugin_registrar.h" 51 "fl_plugin_registry.h" 52 "fl_standard_message_codec.h" 53 "fl_standard_method_codec.h" 54 "fl_string_codec.h" 55 "fl_value.h" 56 "fl_view.h" 57 "flutter_linux.h" 58) 59list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60add_library(flutter INTERFACE) 61target_include_directories(flutter INTERFACE 62 "${EPHEMERAL_DIR}" 63) 64target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65target_link_libraries(flutter INTERFACE 66 PkgConfig::GTK 67 PkgConfig::GLIB 68 PkgConfig::GIO 69) 70add_dependencies(flutter flutter_assemble) 71 72# === Flutter tool backend === 73# _phony_ is a non-existent file to force this command to run every time, 74# since currently there's no way to get a full input/output list from the 75# flutter tool. 76add_custom_command( 77 OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 COMMAND ${CMAKE_COMMAND} -E env 80 ${FLUTTER_TOOL_ENVIRONMENT} 81 "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 VERBATIM 84) 85add_custom_target(flutter_assemble DEPENDS 86 "${FLUTTER_LIBRARY}" 87 ${FLUTTER_LIBRARY_HEADERS} 88)