This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
forked from chinmaygarde/flutter_wayland
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
116 lines (91 loc) · 3.28 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright 2018 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.5.2)
project(flutter_wayland)
if(NOT FLUTTER_ENGINE_LIBRARY AND NOT CMAKE_CROSSCOMPILING)
if(NOT FLUTTER_ENGINE_SHA)
if(NOT CHANNEL)
set(CHANNEL "dev" CACHE STRING "Choose the channel, options are: master, dev, beta, stable" FORCE)
message(STATUS "Flutter Channel not set, defaulting to dev")
endif()
message(STATUS "Flutter Channel ........ ${CHANNEL}")
include(FetchContent)
FetchContent_Declare(engine-version
URL https://raw.githubusercontent.com/flutter/flutter/${CHANNEL}/bin/internal/engine.version
DOWNLOAD_NAME engine.version
DOWNLOAD_NO_EXTRACT TRUE
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
)
FetchContent_GetProperties(engine-version)
if(NOT engine-version_POPULATED)
FetchContent_Populate(engine-version)
file(READ ${CMAKE_BINARY_DIR}/engine.version FLUTTER_ENGINE_SHA)
string(REPLACE "\n" "" FLUTTER_ENGINE_SHA ${FLUTTER_ENGINE_SHA})
else()
MESSAGE(FATAL "Unable to determine engine-version, please override FLUTTER_ENGINE_SHA")
endif()
endif()
message(STATUS "Engine SHA1 ............ ${FLUTTER_ENGINE_SHA}")
# Download and setup the Flutter Engine.
set(FLUTTER_EMBEDDER_ARTIFACTS_ZIP ${CMAKE_BINARY_DIR}/flutter_embedder_${FLUTTER_ENGINE_SHA}.zip)
set(FLUTTER_BUCKET_BASE "https://storage.googleapis.com/flutter_infra/flutter")
if(NOT EXISTS ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP})
file(DOWNLOAD
${FLUTTER_BUCKET_BASE}/${FLUTTER_ENGINE_SHA}/linux-x64/linux-x64-embedder
${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
SHOW_PROGRESS
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
set(FLUTTER_ENGINE_LIBRARY ${CMAKE_BINARY_DIR}/libflutter_engine.so)
else()
message(STATUS "Engine ................. ${FLUTTER_ENGINE_LIBRARY}")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
include(FindPkgConfig)
pkg_check_modules(WAYLANDPP REQUIRED
wayland-client-extra++>=0.2.7
wayland-client++>=0.2.7
wayland-client-unstable++>=0.2.7
wayland-cursor++>=0.2.7
wayland-egl++>=0.2.7
wayland-client++>=0.2.7
)
pkg_check_modules(EGL REQUIRED egl)
pkg_check_modules(XKBCOMMON REQUIRED xkbcommon)
pkg_check_modules(RAPIDJSON REQUIRED "RapidJSON>=1.1.0")
set(FLUTTER_WAYLAND_SRC
flutter/standard_codec.cc
src/wayland_display.cc
src/keyboard.cc
src/platform_channel.cc
src/utils.cc
src/main.cc
)
link_directories(${CMAKE_BINARY_DIR})
add_executable(flutter_wayland ${FLUTTER_WAYLAND_SRC})
target_link_libraries(flutter_wayland dl
${FLUTTER_ENGINE_LIBRARY}
${XKBCOMMON_LINK_LIBRARIES}
${RAPIDJSON_LINK_LIBRARIES}
${WAYLANDPP_LINK_LIBRARIES}
${EGL_LDFLAGS}
)
link_directories()
target_include_directories(flutter_wayland
PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${WAYLANDPP_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
${XKBCOMMON_INCLUDE_DIRS}
${RAPIDJSON_INCLUDE_DIRS}
)
target_compile_options(flutter_wayland PUBLIC ${EGL_CFLAGS})
install(TARGETS flutter_wayland RUNTIME DESTINATION bin)