@@ -161,10 +161,6 @@ include_directories(${PROJECT_BINARY_DIR}/third_party) # Tablegen'd files
161161add_subdirectory (include )
162162add_subdirectory (lib)
163163
164- # find_package(PythonLibs REQUIRED)
165- set (TRITON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} " )
166- set (TRITON_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
167-
168164# TODO: Figure out which target is sufficient to fix errors; triton is
169165# apparently not enough. Currently set linking libstdc++fs for all targets
170166# to support some old version GCC compilers like 8.3.0.
@@ -181,22 +177,9 @@ if(TRITON_BUILD_PYTHON_MODULE)
181177 set (PYTHON_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR} /python/src)
182178 include_directories (${PYTHON_SRC_PATH} )
183179
184- if (PYTHON_INCLUDE_DIRS)
185- # We have PYTHON_INCLUDE_DIRS set--this is what we expect when building
186- # using pip install.
187- include_directories (${PYTHON_INCLUDE_DIRS} )
188- include_directories (${PYBIND11_INCLUDE_DIR} )
189- else ()
190- # Otherwise, we might be building from top CMakeLists.txt directly.
191- # Try to find Python and pybind11 packages.
192- find_package (Python3 REQUIRED COMPONENTS Development Interpreter)
193- find_package (pybind11 CONFIG REQUIRED HINTS "${Python3_SITELIB} " )
194- include_directories (${Python3_INCLUDE_DIRS} )
195- include_directories (${pybind11_INCLUDE_DIR} )
196- link_directories (${Python3_LIBRARY_DIRS} )
197- link_libraries (${Python3_LIBRARIES} )
198- add_link_options (${Python3_LINK_OPTIONS} )
199- endif ()
180+ # Python Interpreter is used to run lit tests
181+ find_package (Python3 REQUIRED COMPONENTS Development Interpreter)
182+ find_package (pybind11 CONFIG REQUIRED HINTS "${Python3_SITELIB} " )
200183
201184 if (DEFINED TRITON_PLUGIN_DIRS)
202185 foreach (PLUGIN_DIR ${TRITON_PLUGIN_DIRS} )
@@ -262,6 +245,9 @@ if(TRITON_BUILD_PYTHON_MODULE)
262245 LLVMAMDGPUCodeGen
263246 LLVMAMDGPUAsmParser
264247
248+ Python3::Module
249+ pybind11::headers
250+
265251 )
266252 if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR # Linux arm64
267253 CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" OR # macOS arm64
@@ -302,7 +288,7 @@ if(TRITON_BUILD_PYTHON_MODULE)
302288 ${PYTHON_SRC_PATH} /llvm.cc)
303289
304290 # Link triton with its dependencies
305- target_link_libraries (triton PUBLIC ${TRITON_LIBRARIES} )
291+ target_link_libraries (triton PRIVATE ${TRITON_LIBRARIES} )
306292 if (WIN32 )
307293 target_link_libraries (triton PRIVATE ${CMAKE_DL_LIBS} )
308294 set_target_properties (triton PROPERTIES SUFFIX ".pyd" )
@@ -325,7 +311,7 @@ if(TRITON_BUILD_PYTHON_MODULE AND NOT WIN32)
325311 set (PYTHON_LDFLAGS "-undefined dynamic_lookup" )
326312 endif ()
327313
328- target_link_libraries (triton PRIVATE ${PYTHON_LDFLAGS} )
314+ target_link_options (triton PRIVATE ${PYTHON_LDFLAGS} )
329315endif ()
330316
331317if (NOT TRITON_BUILD_PYTHON_MODULE)
0 commit comments