Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes for Cross-Compilation Issues #272

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/elinux_build_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,7 @@ class NativeBundle {
eLinuxDir.path,
],
workingDirectory: outputDir.path,
environment: (targetToolchain == null)
? <String, String>{'CC': 'clang', 'CXX': 'clang++'}
: <String, String>{
'CC': '$targetToolchain/bin/clang',
'CXX': '$targetToolchain/bin/clang++'
},
environment: _buildCMakeEnvironment(targetToolchain),
);
if (result.exitCode != 0) {
throwToolExit('Failed to cmake:\n$result');
Expand Down Expand Up @@ -432,6 +427,18 @@ class NativeBundle {
}
}

Map<String, String> _buildCMakeEnvironment(String? targetToolchain) {
final String? ccEnv = Platform.environment['CC'];
final String? cxxEnv = Platform.environment['CXX'];

final String cc = ccEnv ??
(targetToolchain != null ? '$targetToolchain/bin/clang' : 'clang');
final String cxx = cxxEnv ??
(targetToolchain != null ? '$targetToolchain/bin/clang++' : 'clang++');

return <String, String>{'CC': cc, 'CXX': cxx};
}

String _getCurrentHostPlatformArchName() {
final HostPlatform hostPlatform = getCurrentHostPlatform();
return hostPlatform.platformName;
Expand Down
29 changes: 29 additions & 0 deletions templates/app/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE "${FLUTTER_EMBEDDER_LIBRARY}")
add_dependencies(flutter flutter_assemble)

# === Find Dependencies ===
find_package(Fontconfig REQUIRED)
find_package(X11 REQUIRED xkbcommon)
find_package(OpenGL REQUIRED COMPONENTS EGL)

# Use pkg-config to find Wayland libraries
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND_EGL REQUIRED wayland-egl)
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
pkg_check_modules(WAYLAND_CURSOR REQUIRED wayland-cursor)

# Link the dependencies to the flutter target
target_link_libraries(flutter INTERFACE
Fontconfig::Fontconfig
X11::xkbcommon
OpenGL::EGL
${WAYLAND_EGL_LIBRARIES}
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_CURSOR_LIBRARIES}
)

# Include directories for the dependencies
target_include_directories(flutter INTERFACE
${X11_INCLUDE_DIR}
${WAYLAND_EGL_INCLUDE_DIRS}
${WAYLAND_CLIENT_INCLUDE_DIRS}
${WAYLAND_CURSOR_INCLUDE_DIRS}
)

# === Wrapper ===
list(APPEND CPP_WRAPPER_SOURCES_CORE
"core_implementations.cc"
Expand Down
Loading