Skip to content

Commit

Permalink
Attempt to add nanobind in the cmake file for C++ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stand-by committed Dec 17, 2024
1 parent d828122 commit 0f27859
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ find_package(OpenMP REQUIRED)

# Setup Python
find_package(Python 3.10 # This is a minimum version
COMPONENTS Interpreter Development.Module REQUIRED)
COMPONENTS Interpreter Development REQUIRED)

# Import nanobind through CMake's find_package mechanism
find_package(nanobind CONFIG REQUIRED)

# Our primary target
add_library(fast_pauli INTERFACE)
Expand Down
7 changes: 6 additions & 1 deletion fast_pauli/cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
# Grab all *.cpp files in the directory
file(GLOB TEST_SRC CONFIGURE_DEPENDS "*.cpp")

# Build the core parts of nanobind once
nanobind_build_library(nanobind-static)

foreach(TEST_SRC_FILE ${TEST_SRC})
# Strip file extension
get_filename_component(TEST_NAME ${TEST_SRC_FILE} NAME_WLE)
# Add test executable
add_executable(${TEST_NAME} ${TEST_SRC_FILE})
target_link_libraries(${TEST_NAME} PUBLIC ${PROJECT_NAME} doctest::doctest)
target_link_libraries(
${TEST_NAME} PUBLIC ${PROJECT_NAME} doctest::doctest nanobind-static
Python::Python Python::Module)
add_test(${TEST_NAME} ${TEST_NAME})
endforeach()

0 comments on commit 0f27859

Please sign in to comment.