nandi/vflutter_ffipublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

CMakeLists.txt · 48 lines · 1.8 KBCMake Blame HistoryRaw
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 5h ago1# Shared CMake logic for every platform that builds the V library from source.
2# Included by android/, linux/ and windows/.
3cmake_minimum_required(VERSION 3.15)
4project(vflutter LANGUAGES C)
5
6find_program(V_EXECUTABLE v REQUIRED
7 DOC "The V compiler. Set -DV_EXECUTABLE=/path/to/v to override.")
8
9set(VF_SRC "${CMAKE_CURRENT_LIST_DIR}/vflutter.v")
10
11# V cross-compiles by emitting C, so the reliable pattern is:
12# V source -> C (V's job) C -> object/library (the platform's toolchain)
13# This keeps the NDK / MSVC / clang in charge of ABI, sysroot and flags.
14set(VF_GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/vflutter.gen.c")
15
16add_custom_command(
17 OUTPUT "${VF_GENERATED_C}"
18 COMMAND "${V_EXECUTABLE}" -shared -gc none -no-parallel -o "${VF_GENERATED_C}" "${VF_SRC}"
19 DEPENDS "${VF_SRC}"
20 COMMENT "v -shared -> C (${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR})"
21 VERBATIM)
22
23add_library(vflutter SHARED "${VF_GENERATED_C}")
24
25target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
26
27# V's generated C is machine output: silence the noise, keep real errors.
Add a Mandelbrot example app, and a V kernel worth demonstrating 81540bb nandithebull 1h ago28#
29# -O2 is set unconditionally, including in Debug. This library is a numeric
30# kernel with no Dart-visible debugger story of its own, and at -O0 the
31# Mandelbrot path runs several times slower than the equivalent Dart — which
32# makes a debug run of the example wildly misrepresent the bridge.
33if(MSVC)
34 target_compile_options(vflutter PRIVATE /O2)
35else()
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 5h ago36 target_compile_options(vflutter PRIVATE
Add a Mandelbrot example app, and a V kernel worth demonstrating 81540bb nandithebull 1h ago37 -O2 -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types)
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 5h ago38endif()
39
40# Boehm GC ships with V and is linked statically by the V toolchain on desktop;
41# on Android it must come from the NDK-built copy. See tool/build_gc.sh.
42if(ANDROID)
43 target_link_libraries(vflutter PRIVATE log)
44endif()
45
46set_target_properties(vflutter PROPERTIES
47 OUTPUT_NAME "vflutter"
48 C_VISIBILITY_PRESET hidden)