@@ -40,32 +40,34 @@ train_xor gflags executorch_core portable_ops_lib extension_tensor
4040)
4141target_compile_options (train_xor PUBLIC ${_common_compile_options} )
4242
43- # Pybind library.
44- set (_pybind_training_dep_libs
45- ${TORCH_PYTHON_LIBRARY}
46- etdump
47- executorch
48- util
49- torch
50- extension_training
51- )
43+ if (EXECUTORCH_BUILD_PYBIND)
44+ # Pybind library.
45+ set (_pybind_training_dep_libs
46+ ${TORCH_PYTHON_LIBRARY}
47+ etdump
48+ executorch
49+ util
50+ torch
51+ extension_training
52+ )
5253
53- if (EXECUTORCH_BUILD_XNNPACK)
54- # need to explicitly specify XNNPACK and microkernels-prod
55- # here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
56- list (APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK microkernels-prod)
57- endif ()
54+ if (EXECUTORCH_BUILD_XNNPACK)
55+ # need to explicitly specify XNNPACK and microkernels-prod
56+ # here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
57+ list (APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK microkernels-prod)
58+ endif ()
5859
59- # pybind training
60- pybind11_add_module(_training_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR} /pybindings/_training_lib.cpp)
60+ # pybind training
61+ pybind11_add_module(_training_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR} /pybindings/_training_lib.cpp)
6162
62- target_include_directories (_training_lib PRIVATE ${TORCH_INCLUDE_DIRS} )
63- target_compile_options (_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions)
64- target_link_libraries (_training_lib PRIVATE ${_pybind_training_dep_libs} )
63+ target_include_directories (_training_lib PRIVATE ${TORCH_INCLUDE_DIRS} )
64+ target_compile_options (_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions)
65+ target_link_libraries (_training_lib PRIVATE ${_pybind_training_dep_libs} )
6566
66- install (TARGETS _training_lib
67- LIBRARY DESTINATION executorch/extension/training/pybindings
68- )
67+ install (TARGETS _training_lib
68+ LIBRARY DESTINATION executorch/extension/training/pybindings
69+ )
70+ endif ()
6971
7072# Install libraries
7173install (
0 commit comments