CMakeLists.txt (3742B)
1 # This file controls Flutter-level build steps. It should not be edited. 2 cmake_minimum_required(VERSION 3.14) 3 4 set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 6 # Configuration provided via flutter tool. 7 include(${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 set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 13 # Set fallback configurations for older versions of the flutter tool. 14 if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 endif() 17 18 # === Flutter Library === 19 set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 21 # Published to parent scope for install step. 22 set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 27 list(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 ) 34 list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 add_library(flutter INTERFACE) 36 target_include_directories(flutter INTERFACE 37 "${EPHEMERAL_DIR}" 38 ) 39 target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 add_dependencies(flutter flutter_assemble) 41 42 # === Wrapper === 43 list(APPEND CPP_WRAPPER_SOURCES_CORE 44 "core_implementations.cc" 45 "standard_codec.cc" 46 ) 47 list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 "plugin_registrar.cc" 50 ) 51 list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 list(APPEND CPP_WRAPPER_SOURCES_APP 53 "flutter_engine.cc" 54 "flutter_view_controller.cc" 55 ) 56 list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 58 # Wrapper sources needed for a plugin. 59 add_library(flutter_wrapper_plugin STATIC 60 ${CPP_WRAPPER_SOURCES_CORE} 61 ${CPP_WRAPPER_SOURCES_PLUGIN} 62 ) 63 apply_standard_settings(flutter_wrapper_plugin) 64 set_target_properties(flutter_wrapper_plugin PROPERTIES 65 POSITION_INDEPENDENT_CODE ON) 66 set_target_properties(flutter_wrapper_plugin PROPERTIES 67 CXX_VISIBILITY_PRESET hidden) 68 target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 target_include_directories(flutter_wrapper_plugin PUBLIC 70 "${WRAPPER_ROOT}/include" 71 ) 72 add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 74 # Wrapper sources needed for the runner. 75 add_library(flutter_wrapper_app STATIC 76 ${CPP_WRAPPER_SOURCES_CORE} 77 ${CPP_WRAPPER_SOURCES_APP} 78 ) 79 apply_standard_settings(flutter_wrapper_app) 80 target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 target_include_directories(flutter_wrapper_app PUBLIC 82 "${WRAPPER_ROOT}/include" 83 ) 84 add_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. 90 set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 add_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 ) 103 add_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 )