File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,6 +136,17 @@ add_library(abacus::feature_libs ALIAS abacus_feature_libs)
136136add_library (abacus_link_libs INTERFACE )
137137add_library (abacus::link_libs ALIAS abacus_link_libs )
138138
139+ if (ENABLE_MLALGO OR DEFINED Torch_DIR)
140+ # TorchConfig.cmake exposes its complete link closure through
141+ # TORCH_LIBRARIES rather than a stable namespaced target. Keep that
142+ # provider-specific representation behind an imported adapter so the
143+ # installed ABACUS package can recreate it after find_dependency(Torch).
144+ add_library (abacus::torch INTERFACE IMPORTED GLOBAL )
145+ target_link_libraries (abacus::torch INTERFACE ${TORCH_LIBRARIES} )
146+ target_include_directories (abacus::torch INTERFACE ${TORCH_INCLUDE_DIRS} )
147+ target_compile_options (abacus::torch INTERFACE ${ABACUS_TORCH_CXX_FLAGS} )
148+ endif ()
149+
139150target_link_libraries (abacus_link_libs INTERFACE
140151 abacus::feature_libs
141152 abacus::linalg_libs )
@@ -263,8 +274,7 @@ if(ENABLE_MLALGO)
263274endif ()
264275
265276if (ENABLE_MLALGO OR DEFINED Torch_DIR)
266- list (APPEND _abacus_feature_include_dirs ${TORCH_INCLUDE_DIRS} )
267- list (APPEND _abacus_feature_compile_options ${ABACUS_TORCH_CXX_FLAGS} )
277+ list (APPEND _abacus_feature_libs abacus::torch)
268278endif ()
269279
270280if (ENABLE_CNPY)
@@ -372,6 +382,7 @@ foreach(_abacus_feature_target IN ITEMS
372382 DeePMD::deepmd_cc
373383 NEP::nep
374384 TensorFlow::tensorflow_cc
385+ abacus::torch
375386 ZLIB::ZLIB
376387 PEXSI::PEXSI
377388 NCCL::NCCL
You can’t perform that action at this time.
0 commit comments