@@ -13,6 +13,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1313set (EXECUTORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR} /../../.." )
1414include (${EXECUTORCH_ROOT} /tools/cmake/Utils.cmake )
1515
16+ if (CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\. toolchain)\. cmake$" )
17+ set (CMAKE_TOOLCHAIN_IOS ON )
18+ else ()
19+ set (CMAKE_TOOLCHAIN_IOS OFF )
20+ endif ()
21+
1622# Let files say "include <executorch/path/to/header.h>"
1723set (_common_include_directories ${EXECUTORCH_ROOT} /..)
1824
@@ -22,23 +28,30 @@ find_package(gflags REQUIRED)
2228
2329list (APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR} /../../..)
2430find_package (executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH )
31+ executorch_target_link_options_shared_lib (executorch )
2532
2633set (_link_libraries executorch gflags)
2734set (_srcs multimodal.cpp)
2835
29- list (
30- APPEND
31- _link_libraries
32- optimized_native_cpu_ops_lib
33- quantized_ops_lib
34- custom_ops
35- cpublas
36- eigen_blas
37- )
36+ # Common ops for all builds
37+ list (APPEND _link_libraries optimized_native_cpu_ops_lib cpublas eigen_blas)
38+ executorch_target_link_options_shared_lib (optimized_native_cpu_ops_lib )
39+
40+ # CPU-only builds need quantized and custom ops
41+ if (NOT EXECUTORCH_BUILD_CUDA AND MSVC )
42+ list (APPEND _link_libraries quantized_ops_lib custom_ops)
43+ executorch_target_link_options_shared_lib (quantized_ops_lib )
44+ executorch_target_link_options_shared_lib (custom_ops )
45+ endif ()
3846
3947# XNNPACK
4048if (TARGET xnnpack_backend)
41- list (APPEND _link_libraries xnnpack_backend)
49+ set (xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
50+ if (TARGET kleidiai)
51+ list (APPEND xnnpack_backend_libs kleidiai)
52+ endif ()
53+ list (APPEND _link_libraries ${xnnpack_backend_libs} )
54+ executorch_target_link_options_shared_lib (xnnpack_backend )
4255endif ()
4356
4457# Add LLM runner and extension module
7083if (EXECUTORCH_BUILD_CUDA)
7184 find_package (CUDAToolkit REQUIRED )
7285 list (APPEND _link_libraries aoti_cuda_backend)
73- executorch_target_link_options_shared_lib (aoti_cuda_backend )
86+ if (NOT MSVC )
87+ # On non-MSVC, use shared lib options
88+ executorch_target_link_options_shared_lib (aoti_cuda_backend )
89+ endif ()
7490endif ()
7591
7692if (EXECUTORCH_BUILD_METAL)
@@ -82,8 +98,24 @@ endif()
8298list (APPEND _link_libraries tokenizers::tokenizers)
8399
84100add_executable (whisper_runner main.cpp )
101+ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
102+ target_link_options_gc_sections (whisper_runner )
103+ if (NOT APPLE AND NOT MSVC )
104+ target_link_options (whisper_runner PRIVATE "LINKER:-s" )
105+ endif ()
106+ endif ()
85107
86108target_include_directories (whisper_runner PUBLIC ${_common_include_directories} )
87-
88109target_link_libraries (whisper_runner PUBLIC ${_link_libraries} )
89110target_compile_options (whisper_runner PUBLIC ${_common_compile_options} )
111+
112+ # On Windows, copy required DLLs to the executable directory
113+ if (MSVC AND EXECUTORCH_BUILD_CUDA)
114+ add_custom_command (
115+ TARGET whisper_runner
116+ POST_BUILD
117+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE :aoti_cuda_shims >
118+ $<TARGET_FILE_DIR :whisper_runner >
119+ COMMENT "Copying aoti_cuda_shims.dll to whisper_runner directory"
120+ )
121+ endif ()
0 commit comments