Advertisement
FlyFar

CMakeLists.txt

Jul 24th, 2023
2,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 3.58 KB | Cybersecurity | 0 0
  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. # === Flutter Library ===
  14. set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
  15.  
  16. # Published to parent scope for install step.
  17. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
  18. set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
  19. set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
  20. set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
  21.  
  22. list(APPEND FLUTTER_LIBRARY_HEADERS
  23.   "flutter_export.h"
  24.   "flutter_windows.h"
  25.   "flutter_messenger.h"
  26.   "flutter_plugin_registrar.h"
  27.   "flutter_texture_registrar.h"
  28. )
  29. list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
  30. add_library(flutter INTERFACE)
  31. target_include_directories(flutter INTERFACE
  32.   "${EPHEMERAL_DIR}"
  33. )
  34. target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
  35. add_dependencies(flutter flutter_assemble)
  36.  
  37. # === Wrapper ===
  38. list(APPEND CPP_WRAPPER_SOURCES_CORE
  39.   "core_implementations.cc"
  40.   "standard_codec.cc"
  41. )
  42. list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
  43. list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
  44.   "plugin_registrar.cc"
  45. )
  46. list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
  47. list(APPEND CPP_WRAPPER_SOURCES_APP
  48.   "flutter_engine.cc"
  49.   "flutter_view_controller.cc"
  50. )
  51. list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
  52.  
  53. # Wrapper sources needed for a plugin.
  54. add_library(flutter_wrapper_plugin STATIC
  55.   ${CPP_WRAPPER_SOURCES_CORE}
  56.   ${CPP_WRAPPER_SOURCES_PLUGIN}
  57. )
  58. apply_standard_settings(flutter_wrapper_plugin)
  59. set_target_properties(flutter_wrapper_plugin PROPERTIES
  60.   POSITION_INDEPENDENT_CODE ON)
  61. set_target_properties(flutter_wrapper_plugin PROPERTIES
  62.   CXX_VISIBILITY_PRESET hidden)
  63. target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
  64. target_include_directories(flutter_wrapper_plugin PUBLIC
  65.   "${WRAPPER_ROOT}/include"
  66. )
  67. add_dependencies(flutter_wrapper_plugin flutter_assemble)
  68.  
  69. # Wrapper sources needed for the runner.
  70. add_library(flutter_wrapper_app STATIC
  71.   ${CPP_WRAPPER_SOURCES_CORE}
  72.   ${CPP_WRAPPER_SOURCES_APP}
  73. )
  74. apply_standard_settings(flutter_wrapper_app)
  75. target_link_libraries(flutter_wrapper_app PUBLIC flutter)
  76. target_include_directories(flutter_wrapper_app PUBLIC
  77.   "${WRAPPER_ROOT}/include"
  78. )
  79. add_dependencies(flutter_wrapper_app flutter_assemble)
  80.  
  81. # === Flutter tool backend ===
  82. # _phony_ is a non-existent file to force this command to run every time,
  83. # since currently there's no way to get a full input/output list from the
  84. # flutter tool.
  85. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
  86. set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
  87. add_custom_command(
  88.   OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
  89.     ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
  90.     ${CPP_WRAPPER_SOURCES_APP}
  91.     ${PHONY_OUTPUT}
  92.   COMMAND ${CMAKE_COMMAND} -E env
  93.     ${FLUTTER_TOOL_ENVIRONMENT}
  94.     "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
  95.       windows-x64 $<CONFIG>
  96.   VERBATIM
  97. )
  98. add_custom_target(flutter_assemble DEPENDS
  99.   "${FLUTTER_LIBRARY}"
  100.   ${FLUTTER_LIBRARY_HEADERS}
  101.   ${CPP_WRAPPER_SOURCES_CORE}
  102.   ${CPP_WRAPPER_SOURCES_PLUGIN}
  103.   ${CPP_WRAPPER_SOURCES_APP}
  104. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement