Skip to content

Commit a21f935

Browse files
committed
Linux/Windows: REALPATH-resolve CMake plugin location before reaching into src/native_bridge/
Flutter symlinks the plugin into <example>/<plat>/flutter/ephemeral/.plugin_symlinks/. CMake follows the symlink to find the CMakeLists.txt but resolves relative add_subdirectory paths against the literal symlink directory, so add_subdirectory("../../native_bridge") lands at the wrong path (<example>/<plat>/flutter/ephemeral/.plugin_symlinks/native_bridge — doesn't exist). Use get_filename_component(... REALPATH) to canonicalize before joining the path. Android isn't affected — gradle doesn't use the .plugin_symlinks mechanism.
1 parent 841cc61 commit a21f935

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎src/serious_python_bridge/linux/CMakeLists.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ cmake_minimum_required(VERSION 3.10)
33
set(PROJECT_NAME "serious_python_bridge")
44
project(${PROJECT_NAME} LANGUAGES C)
55

6-
add_subdirectory("../../native_bridge" "${CMAKE_CURRENT_BINARY_DIR}/shared")
6+
# Flutter symlinks the plugin into <example>/linux/flutter/ephemeral/
7+
# .plugin_symlinks/serious_python_bridge — CMake follows the symlink to find
8+
# this file but resolves relative add_subdirectory paths against the literal
9+
# symlink location, not the canonical source. REALPATH-resolve first so
10+
# ../../native_bridge lands at <repo>/src/native_bridge regardless of how
11+
# Flutter staged the plugin.
12+
get_filename_component(_real_list_dir "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
13+
get_filename_component(_native_bridge_dir "${_real_list_dir}/../../native_bridge" REALPATH)
14+
add_subdirectory("${_native_bridge_dir}" "${CMAKE_CURRENT_BINARY_DIR}/shared")
715

816
# Flutter picks up bundled libraries via this variable and copies the file
917
# alongside the app binary; Dart resolves it via DynamicLibrary.open.

‎src/serious_python_bridge/windows/CMakeLists.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ set(FLET_BRIDGE_PYTHON_LIBRARIES
3939
"${PYTHON_DOWNLOAD_DIR}/libs/python3$<$<CONFIG:Debug>:_d>.lib"
4040
)
4141

42-
add_subdirectory("../../native_bridge" "${CMAKE_CURRENT_BINARY_DIR}/shared")
42+
# Flutter symlinks the plugin into <example>/windows/flutter/ephemeral/
43+
# .plugin_symlinks/serious_python_bridge — CMake follows the symlink to find
44+
# this file but resolves relative add_subdirectory paths against the literal
45+
# symlink location, not the canonical source. REALPATH-resolve first so
46+
# ../../native_bridge lands at <repo>/src/native_bridge regardless of how
47+
# Flutter staged the plugin.
48+
get_filename_component(_real_list_dir "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
49+
get_filename_component(_native_bridge_dir "${_real_list_dir}/../../native_bridge" REALPATH)
50+
add_subdirectory("${_native_bridge_dir}" "${CMAKE_CURRENT_BINARY_DIR}/shared")
4351

4452
# Make python-windows-for-dart's libs/ visible to MSVC's auto-link. pyconfig.h
4553
# emits `#pragma comment(lib, "pythonXY(_d).lib")` and MSVC's default LIB path

0 commit comments

Comments
 (0)