at main 3.7 kB view raw
1# This file controls Flutter-level build steps. It should not be edited. 2cmake_minimum_required(VERSION 3.14) 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. 11set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 13# Set fallback configurations for older versions of the flutter tool. 14if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 set(FLUTTER_TARGET_PLATFORM "windows-x64") 16endif() 17 18# === Flutter Library === 19set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 21# Published to parent scope for install step. 22set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 27list(APPEND FLUTTER_LIBRARY_HEADERS 28 "flutter_export.h" 29 "flutter_windows.h" 30 "flutter_messenger.h" 31 "flutter_plugin_registrar.h" 32 "flutter_texture_registrar.h" 33) 34list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35add_library(flutter INTERFACE) 36target_include_directories(flutter INTERFACE 37 "${EPHEMERAL_DIR}" 38) 39target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40add_dependencies(flutter flutter_assemble) 41 42# === Wrapper === 43list(APPEND CPP_WRAPPER_SOURCES_CORE 44 "core_implementations.cc" 45 "standard_codec.cc" 46) 47list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 "plugin_registrar.cc" 50) 51list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52list(APPEND CPP_WRAPPER_SOURCES_APP 53 "flutter_engine.cc" 54 "flutter_view_controller.cc" 55) 56list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 58# Wrapper sources needed for a plugin. 59add_library(flutter_wrapper_plugin STATIC 60 ${CPP_WRAPPER_SOURCES_CORE} 61 ${CPP_WRAPPER_SOURCES_PLUGIN} 62) 63apply_standard_settings(flutter_wrapper_plugin) 64set_target_properties(flutter_wrapper_plugin PROPERTIES 65 POSITION_INDEPENDENT_CODE ON) 66set_target_properties(flutter_wrapper_plugin PROPERTIES 67 CXX_VISIBILITY_PRESET hidden) 68target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69target_include_directories(flutter_wrapper_plugin PUBLIC 70 "${WRAPPER_ROOT}/include" 71) 72add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 74# Wrapper sources needed for the runner. 75add_library(flutter_wrapper_app STATIC 76 ${CPP_WRAPPER_SOURCES_CORE} 77 ${CPP_WRAPPER_SOURCES_APP} 78) 79apply_standard_settings(flutter_wrapper_app) 80target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81target_include_directories(flutter_wrapper_app PUBLIC 82 "${WRAPPER_ROOT}/include" 83) 84add_dependencies(flutter_wrapper_app flutter_assemble) 85 86# === Flutter tool backend === 87# _phony_ is a non-existent file to force this command to run every time, 88# since currently there's no way to get a full input/output list from the 89# flutter tool. 90set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92add_custom_command( 93 OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 ${CPP_WRAPPER_SOURCES_APP} 96 ${PHONY_OUTPUT} 97 COMMAND ${CMAKE_COMMAND} -E env 98 ${FLUTTER_TOOL_ENVIRONMENT} 99 "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 ${FLUTTER_TARGET_PLATFORM} $<CONFIG> 101 VERBATIM 102) 103add_custom_target(flutter_assemble DEPENDS 104 "${FLUTTER_LIBRARY}" 105 ${FLUTTER_LIBRARY_HEADERS} 106 ${CPP_WRAPPER_SOURCES_CORE} 107 ${CPP_WRAPPER_SOURCES_PLUGIN} 108 ${CPP_WRAPPER_SOURCES_APP} 109)