Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion mlir/cmake/modules/AddMLIRPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,25 @@ function(add_mlir_python_extension libname extname)

if (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)
# Avoids warnings from upstream nanobind.
target_compile_options(nanobind-static
set(nanobind_target "nanobind-static")
if (NOT TARGET ${nanobind_target})
# Get correct nanobind target name: nanobind-static-ft or something else
# It is set by nanobind_add_module function according to the passed options
get_property(all_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)

# Iterate over the list of targets
foreach(target ${all_targets})
# Check if the target name matches the given string
if("${target}" MATCHES "nanobind-")
set(nanobind_target "${target}")
endif()
endforeach()
Comment on lines +676 to +688
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the following work instead of iterating over the list of all targets:

get_property(nanobind_target TARGET ${libname} PROPERTY LINK_LIBRARIES)


if (NOT TARGET ${nanobind_target})
message(FATAL_ERROR "Could not find nanobind target to set compile options to")
endif()
endif()
target_compile_options(${nanobind_target}
PRIVATE
-Wno-cast-qual
-Wno-zero-length-array
Expand Down
Loading