@@ -168,10 +168,6 @@ include_directories(${PROJECT_BINARY_DIR}/third_party) # Tablegen'd files
168168add_subdirectory (include )
169169add_subdirectory (lib)
170170
171- # find_package(PythonLibs REQUIRED)
172- set (TRITON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} " )
173- set (TRITON_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
174-
175171# TODO: Figure out which target is sufficient to fix errors; triton is
176172# apparently not enough. Currently set linking libstdc++fs for all targets
177173# to support some old version GCC compilers like 8.3.0.
@@ -188,24 +184,9 @@ if(TRITON_BUILD_PYTHON_MODULE)
188184 set (PYTHON_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR} /python/src)
189185 include_directories (${PYTHON_SRC_PATH} )
190186
191- if (PYTHON_INCLUDE_DIRS)
192- # We have PYTHON_INCLUDE_DIRS set--this is what we expect when building
193- # using pip install.
194- include_directories (${PYTHON_INCLUDE_DIRS} )
195- include_directories (${PYBIND11_INCLUDE_DIR} )
196- message (STATUS "PYTHON_LIB_DIRS ${PYTHON_LIB_DIRS} " )
197- link_directories (${PYTHON_LIB_DIRS} )
198- else ()
199- # Otherwise, we might be building from top CMakeLists.txt directly.
200- # Try to find Python and pybind11 packages.
201- find_package (Python3 REQUIRED COMPONENTS Development Interpreter)
202- find_package (pybind11 CONFIG REQUIRED HINTS "${Python3_SITELIB} " )
203- include_directories (${Python3_INCLUDE_DIRS} )
204- include_directories (${pybind11_INCLUDE_DIR} )
205- link_directories (${Python3_LIBRARY_DIRS} )
206- link_libraries (${Python3_LIBRARIES} )
207- add_link_options (${Python3_LINK_OPTIONS} )
208- endif ()
187+ # Python Interpreter is used to run lit tests
188+ find_package (Python3 REQUIRED COMPONENTS Development Interpreter)
189+ find_package (pybind11 CONFIG REQUIRED HINTS "${Python3_SITELIB} " )
209190
210191 if (DEFINED TRITON_PLUGIN_DIRS)
211192 foreach (PLUGIN_DIR ${TRITON_PLUGIN_DIRS} )
@@ -272,6 +253,9 @@ if(TRITON_BUILD_PYTHON_MODULE)
272253 LLVMAMDGPUCodeGen
273254 LLVMAMDGPUAsmParser
274255
256+ Python3::Module
257+ pybind11::headers
258+
275259 )
276260 if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR # Linux arm64
277261 CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" OR # macOS arm64
@@ -312,7 +296,7 @@ if(TRITON_BUILD_PYTHON_MODULE)
312296 ${PYTHON_SRC_PATH} /llvm.cc)
313297
314298 # Link triton with its dependencies
315- target_link_libraries (triton PUBLIC ${TRITON_LIBRARIES} )
299+ target_link_libraries (triton PRIVATE ${TRITON_LIBRARIES} )
316300 if (WIN32 )
317301 target_link_libraries (triton PRIVATE ${CMAKE_DL_LIBS} )
318302 set_target_properties (triton PROPERTIES SUFFIX ".pyd" )
@@ -335,7 +319,7 @@ if(TRITON_BUILD_PYTHON_MODULE AND NOT WIN32)
335319 set (PYTHON_LDFLAGS "-undefined dynamic_lookup" )
336320 endif ()
337321
338- target_link_libraries (triton PRIVATE ${PYTHON_LDFLAGS} )
322+ target_link_options (triton PRIVATE ${PYTHON_LDFLAGS} )
339323endif ()
340324
341325if (NOT TRITON_BUILD_PYTHON_MODULE)
0 commit comments