@@ -33,7 +33,7 @@ include(ExternalProject)
3333# ------------------------------------------------------------------------------
3434
3535# Where to place PyTorch after installation
36- set (PYTORCH_INSTALL_DIR "${CMAKE_BINARY_DIR } /pytorch-install" )
36+ set (PYTORCH_INSTALL_DIR "${PROJECT_BINARY_DIR } /pytorch-install" )
3737
3838# ExternalProject_Add can fetch from Git, a local path, or a release tarball.
3939# Here, for simplicity, we'll fetch from Git. In practice, you might want
@@ -45,6 +45,8 @@ ExternalProject_Add(
4545 GIT_TAG v2.6.0 # Example: specify a particular release
4646 UPDATE_COMMAND "" # Don’t auto-run 'git pull'
4747 PATCH_COMMAND "" # No custom patch step
48+
49+ # DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/pytorch-download" # Where to download the repo
4850
4951 # We need all PyTorch submodules. By default, ExternalProject won't do submodule init.
5052 # So we can do that in a separate step if we want a full build. For a minimal CPU build,
@@ -66,8 +68,21 @@ ExternalProject_Add(
6668 -DCMAKE_INSTALL_PREFIX=${PYTORCH_INSTALL_DIR}
6769
6870 INSTALL_DIR ${PYTORCH_INSTALL_DIR} # Where to install
71+
72+ LOG_DOWNLOAD ON
73+ LOG_UPDATE ON
74+ LOG_PATCH ON
75+ LOG_CONFIGURE ON
76+ # LOG_BUILD ON
77+ LOG_INSTALL ON
78+
6979)
7080
81+
82+ file (GLOB_RECURSE PYTORCH_INCLUDES "${PYTORCH_INSTALL_DIR} /include" "*.h" )
83+ file (GLOB_RECURSE PYTORCH_LIBS "${PYTORCH_INSTALL_DIR} /lib" "*.a" )
84+
85+
7186# ------------------------------------------------------------------------------
7287# 2) Create an INTERFACE library to wrap the installed static libs
7388# ------------------------------------------------------------------------------
@@ -95,6 +110,8 @@ target_link_libraries(torch_interface INTERFACE
95110 "${PYTORCH_INSTALL_DIR} /lib/libtorch_cpu.a"
96111 "${PYTORCH_INSTALL_DIR} /lib/libc10.a"
97112
113+ ${PYTORCH_LIBS}
114+
98115 # System libraries often needed:
99116 pthread
100117 dl
@@ -114,35 +131,38 @@ target_include_directories(torchbridge PUBLIC
114131 "${PYTORCH_INSTALL_DIR} /include/torch/csrc/api/include"
115132 "${PROJECT_ROOT_DIR} /include"
116133)
117- target_link_directories (torchbridge PUBLIC
118- "${PYTORCH_INSTALL_DIR} /lib"
119- )
120- target_link_libraries (torchbridge torch_interface )
121-
122-
123-
124-
125-
126- # add_executable(TorchBridge lib/Bridge.chpl include/bridge.h)
127-
128- # target_link_options(TorchBridge
129- # PRIVATE
130- # "${PROJECT_ROOT_DIR}/include/bridge.h"
131- # "-L${PROJECT_BINARY_DIR}"
132- # -L.
133- # "-ltorchbridge"
134- # "-I${PROJECT_BINARY_DIR}"
135- # "-L${PYTORCH_INSTALL_DIR}/lib"
136- # "-I${PYTORCH_INSTALL_DIR}/include"
137- # "-I${PYTORCH_INSTALL_DIR}/include/torch/csrc/api/include"
138- # "-ltorch"
139- # "-ltorch_cpu"
140- # "-lcpuinfo"
141- # "-lc10"
142- # "-lpthread"
143- # "-ldl"
144-
145- # )
134+ # target_link_directories(torchbridge PUBLIC
135+ # "${PYTORCH_INSTALL_DIR}/lib"
136+ # )
137+ target_link_libraries (torchbridge
138+ torch_interface
139+ ${PYTORCH_LIBS}
140+ )
141+
142+
143+
144+
145+
146+ add_executable (Bridge lib/Bridge.chpl include /bridge.h )
147+ # add_dependencies(TorchBridge torchbridge)
148+
149+ target_link_options (Bridge
150+ PRIVATE
151+ "${PROJECT_ROOT_DIR} /include/bridge.h"
152+ "-L${PROJECT_BINARY_DIR} "
153+ -L.
154+ "-ltorchbridge"
155+ "-I${PROJECT_BINARY_DIR} "
156+ "-L${PYTORCH_INSTALL_DIR} /lib"
157+ "-I${PYTORCH_INSTALL_DIR} /include"
158+ "-I${PYTORCH_INSTALL_DIR} /include/torch/csrc/api/include"
159+ "-ltorch"
160+ "-ltorch_cpu"
161+ "-lcpuinfo"
162+ "-lc10"
163+ "-lpthread"
164+ "-ldl"
165+ )
146166
147167
148168
0 commit comments