Skip to content

Commit

Permalink
Build nanobind with their own cmake function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed May 15, 2024
1 parent 28c39f7 commit ed166e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 34 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ if(NRN_ENABLE_PYTHON)
# Make sure the USE_PYTHON macro is defined in the C++ code
list(APPEND NRN_COMPILE_DEFS USE_PYTHON)
# Ensure nanobind is there, but dont import, we don't want its CMake
nrn_add_external_project(nanobind False)
include(NanoBindMinimal)
nrn_add_external_project(nanobind)
endif()

# =============================================================================
Expand Down
28 changes: 0 additions & 28 deletions cmake/NanoBindMinimal.cmake

This file was deleted.

12 changes: 8 additions & 4 deletions src/nrnpython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ if(NRN_ENABLE_PYTHON_DYNAMIC)
list(GET NRN_PYTHON_VERSIONS ${val} pyver)
list(GET NRN_PYTHON_INCLUDES ${val} pyinc)
list(GET NRN_PYTHON_LIBRARIES ${val} pylib)
set(nanobind_target "nanobind_py${pyver}")
make_nanobind_target(${nanobind_target} ${pyinc})
set(nanobind_target "nanobind_py${pyver}-static")
nanobind_build_library(${nanobind_target})
target_include_directories(${nanobind_target} PUBLIC ${pyinc})
add_library(nrnpython${pyver} SHARED ${NRNPYTHON_FILES_LIST})
target_include_directories(nrnpython${pyver} BEFORE PUBLIC ${pyinc} ${INCLUDE_DIRS})
target_link_libraries(nrnpython${pyver} PUBLIC nrniv_lib)
target_link_libraries(nrnpython${pyver} PRIVATE ${Readline_LIBRARY} ${nanobind_target})
if(NRN_LINK_AGAINST_PYTHON)
target_link_libraries(${nanobind_target} ${pylib})
target_link_libraries(nrnpython${pyver} PUBLIC ${pylib})
endif()
add_dependencies(nrnpython${pyver} nrniv_lib)
Expand All @@ -71,8 +73,10 @@ else()
target_link_libraries(nrnpython PUBLIC ${NRN_DEFAULT_PYTHON_LIBRARIES})
target_include_directories(nrnpython PUBLIC ${PROJECT_SOURCE_DIR}/${NRN_3RDPARTY_DIR}/eigen)
target_include_directories(nrnpython PUBLIC ${PROJECT_BINARY_DIR}/src/nrniv/oc_generated)
make_nanobind_target(nanobind ${NRN_DEFAULT_PYTHON_INCLUDES})
target_link_libraries(nrnpython PUBLIC nanobind)
nanobind_build_library(nanobind-static)
target_include_directories(nanobind-static PUBLIC ${NRN_DEFAULT_PYTHON_INCLUDES})
target_link_libraries(nanobind-static ${NRN_DEFAULT_PYTHON_LIBRARIES})
target_link_libraries(nrnpython PUBLIC nanobind-static)
endif()

configure_file(_config_params.py.in "${PROJECT_BINARY_DIR}/lib/python/neuron/_config_params.py"
Expand Down

0 comments on commit ed166e1

Please sign in to comment.