You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.5 KiB
109 lines
3.5 KiB
5 years ago
|
cmake_minimum_required(VERSION 3.10)
|
||
|
|
||
|
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||
|
|
||
|
# Configuration provided via flutter tool.
|
||
|
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||
|
|
||
|
# TODO: Move the rest of this into files in ephemeral. See
|
||
|
# https://github.com/flutter/flutter/issues/57146.
|
||
|
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper_glfw")
|
||
|
|
||
|
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||
|
# which isn't available in 3.10.
|
||
|
function(list_prepend LIST_NAME PREFIX)
|
||
|
set(NEW_LIST "")
|
||
|
foreach(element ${${LIST_NAME}})
|
||
|
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||
|
endforeach(element)
|
||
|
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||
|
endfunction()
|
||
|
|
||
|
# === Flutter Library ===
|
||
|
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_glfw.so")
|
||
|
|
||
|
# Published to parent scope for install step.
|
||
|
set(FLUTTER_LIBRARY_DIR "${EPHEMERAL_DIR}" PARENT_SCOPE)
|
||
|
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||
|
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||
|
|
||
|
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||
|
"flutter_export.h"
|
||
|
"flutter_glfw.h"
|
||
|
"flutter_messenger.h"
|
||
|
"flutter_plugin_registrar.h"
|
||
|
)
|
||
|
list_prepend(FLUTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/")
|
||
|
add_library(flutter INTERFACE)
|
||
|
target_include_directories(flutter INTERFACE
|
||
|
"${EPHEMERAL_DIR}"
|
||
|
)
|
||
|
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||
|
add_dependencies(flutter flutter_assemble)
|
||
|
|
||
|
# === Wrapper ===
|
||
|
list(APPEND CPP_WRAPPER_SOURCES_CORE
|
||
|
"engine_method_result.cc"
|
||
|
"standard_codec.cc"
|
||
|
)
|
||
|
list_prepend(CPP_WRAPPER_SOURCES_CORE "${WRAPPER_ROOT}/")
|
||
|
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
|
||
|
"plugin_registrar.cc"
|
||
|
)
|
||
|
list_prepend(CPP_WRAPPER_SOURCES_PLUGIN "${WRAPPER_ROOT}/")
|
||
|
list(APPEND CPP_WRAPPER_SOURCES_APP
|
||
|
"flutter_engine.cc"
|
||
|
"flutter_window_controller.cc"
|
||
|
)
|
||
|
list_prepend(CPP_WRAPPER_SOURCES_APP "${WRAPPER_ROOT}/")
|
||
|
|
||
|
# Wrapper sources needed for a plugin.
|
||
|
add_library(flutter_wrapper_plugin STATIC
|
||
|
${CPP_WRAPPER_SOURCES_CORE}
|
||
|
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||
|
)
|
||
|
apply_standard_settings(flutter_wrapper_plugin)
|
||
|
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||
|
POSITION_INDEPENDENT_CODE ON)
|
||
|
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||
|
CXX_VISIBILITY_PRESET hidden)
|
||
|
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
|
||
|
target_include_directories(flutter_wrapper_plugin PUBLIC
|
||
|
"${WRAPPER_ROOT}/include"
|
||
|
)
|
||
|
add_dependencies(flutter_wrapper_plugin flutter_assemble)
|
||
|
|
||
|
# Wrapper sources needed for the runner.
|
||
|
add_library(flutter_wrapper_app STATIC
|
||
|
${CPP_WRAPPER_SOURCES_CORE}
|
||
|
${CPP_WRAPPER_SOURCES_APP}
|
||
|
)
|
||
|
apply_standard_settings(flutter_wrapper_app)
|
||
|
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
|
||
|
target_include_directories(flutter_wrapper_app PUBLIC
|
||
|
"${WRAPPER_ROOT}/include"
|
||
|
)
|
||
|
add_dependencies(flutter_wrapper_app flutter_assemble)
|
||
|
|
||
|
# === Flutter tool backend ===
|
||
|
# _phony_ is a non-existent file to force this command to run every time,
|
||
|
# since currently there's no way to get a full input/output list from the
|
||
|
# flutter tool.
|
||
|
add_custom_command(
|
||
|
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||
|
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
|
||
|
${CPP_WRAPPER_SOURCES_APP}
|
||
|
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||
|
COMMAND ${CMAKE_COMMAND} -E env
|
||
|
${FLUTTER_TOOL_ENVIRONMENT}
|
||
|
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||
|
linux-x64 ${CMAKE_BUILD_TYPE}
|
||
|
)
|
||
|
add_custom_target(flutter_assemble DEPENDS
|
||
|
"${FLUTTER_LIBRARY}"
|
||
|
${FLUTTER_LIBRARY_HEADERS}
|
||
|
${CPP_WRAPPER_SOURCES_CORE}
|
||
|
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||
|
${CPP_WRAPPER_SOURCES_APP}
|
||
|
)
|