Skip to content

Commit

Permalink
Make stub generation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Aug 8, 2024
1 parent eacf0ea commit 609c415
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include(${JRL_CMAKE_MODULES}/python.cmake)
include(${JRL_CMAKE_MODULES}/python-helpers.cmake)

option(GENERATE_PYTHON_STUBS "Generate Python stubs" OFF)

findpython(REQUIRED Development.Module)
set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})

Expand Down Expand Up @@ -46,16 +48,18 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
set_target_properties(instructionset PROPERTIES INSTALL_RPATH
"\$ORIGIN/../../..")
endif()
nanobind_add_stub(
instructionset_stub
MODULE
instructionset
OUTPUT
instructionset.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:instructionset>
DEPENDS
instructionset)
if(GENERATE_PYTHON_STUBS)
nanobind_add_stub(
instructionset_stub
MODULE
instructionset
OUTPUT
instructionset.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:instructionset>
DEPENDS
instructionset)
endif()
install(
TARGETS instructionset
EXPORT ${TARGETS_EXPORT_NAME}
Expand Down Expand Up @@ -127,16 +131,18 @@ function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
"\$ORIGIN/../../..")
endif()

nanobind_add_stub(
${target_name}_stub
MODULE
${target_name}
OUTPUT
${target_name}.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:${target_name}>
DEPENDS
${target_name})
if(GENERATE_PYTHON_STUBS)
nanobind_add_stub(
${target_name}_stub
MODULE
${target_name}
OUTPUT
${target_name}.pyi
PYTHON_PATH
$<TARGET_FILE_DIR:${target_name}>
DEPENDS
${target_name})
endif()

install(TARGETS ${target_name} DESTINATION ${${PYWRAP}_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.pyi
Expand Down

0 comments on commit 609c415

Please sign in to comment.