File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,21 @@ target_include_directories(
4848set (BRIDGE_OBJECT_FILES $<TARGET_OBJECTS :bridge >)
4949
5050
51+ file (GLOB PYTORCH_LIBS "${LIBTORCH_DIR} /lib/*.a" "${LIBTORCH_DIR} /lib/*.dylib" "${LIBTORCH_DIR} /lib/*.so" )
52+
53+ set (PYTORCH_LIBS_LINKER_ARGS "-ltorch" ) # Will hold the list of "-l..." flags.
54+ foreach (lib_path IN LISTS PYTORCH_LIBS)
55+ # Get just the filename without the directory or extension
56+ get_filename_component (lib_name "${lib_path} " NAME_WE )
57+ # If it starts with "lib", strip that off
58+ string (REGEX REPLACE "^lib" "" lib_name "${lib_name} " )
59+ # Now prepend "-l" to the actual library name
60+ list (APPEND PYTORCH_LIBS_LINKER_ARGS "-l${lib_name} " )
61+ endforeach ()
62+
63+ # cmake_print_variables(PYTORCH_LIBS)
64+ cmake_print_variables (PYTORCH_LIBS_LINKER_ARGS )
65+
5166add_executable (TorchBridge ${BRIDGE_DIR} /lib/Bridge.chpl )
5267add_dependencies (TorchBridge bridge )
5368target_link_options (TorchBridge
@@ -58,6 +73,7 @@ target_link_options(TorchBridge
5873 "-ltorch"
5974 "-ltorch_cpu"
6075 "-lc10"
76+ ${PYTORCH_LIBS_LINKER_ARGS}
6177 --ldflags "-Wl,-rpath,${LIBTORCH_DIR} /lib"
6278)
63- install (TARGETS TorchBridge DESTINATION "." )
79+ # install(TARGETS TorchBridge DESTINATION ".")
You can’t perform that action at this time.
0 commit comments