# Shared CMake logic for every platform that builds the V library from source. # Included by android/, linux/ and windows/. cmake_minimum_required(VERSION 3.15) project(vflutter LANGUAGES C) find_program(V_EXECUTABLE v REQUIRED DOC "The V compiler. Set -DV_EXECUTABLE=/path/to/v to override.") set(VF_SRC "${CMAKE_CURRENT_LIST_DIR}/vflutter.v") # V cross-compiles by emitting C, so the reliable pattern is: # V source -> C (V's job) C -> object/library (the platform's toolchain) # This keeps the NDK / MSVC / clang in charge of ABI, sysroot and flags. set(VF_GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/vflutter.gen.c") add_custom_command( OUTPUT "${VF_GENERATED_C}" COMMAND "${V_EXECUTABLE}" -shared -gc none -no-parallel -o "${VF_GENERATED_C}" "${VF_SRC}" DEPENDS "${VF_SRC}" COMMENT "v -shared -> C (${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR})" VERBATIM) add_library(vflutter SHARED "${VF_GENERATED_C}") target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}") # V's generated C is machine output: silence the noise, keep real errors. if(NOT MSVC) target_compile_options(vflutter PRIVATE -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types) endif() # Boehm GC ships with V and is linked statically by the V toolchain on desktop; # on Android it must come from the NDK-built copy. See tool/build_gc.sh. if(ANDROID) target_link_libraries(vflutter PRIVATE log) endif() set_target_properties(vflutter PROPERTIES OUTPUT_NAME "vflutter" C_VISIBILITY_PRESET hidden)