From 0f27859a68c21cb442cb395a06785350857305c4 Mon Sep 17 00:00:00 2001 From: Eugene Rublenko <16805621+stand-by@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:34:24 -0500 Subject: [PATCH] Attempt to add nanobind in the cmake file for C++ tests --- CMakeLists.txt | 5 ++++- fast_pauli/cpp/tests/CMakeLists.txt | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18d1243..8defca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/fast_pauli/cpp/tests/CMakeLists.txt b/fast_pauli/cpp/tests/CMakeLists.txt index 6667c35..ab9a0c7 100644 --- a/fast_pauli/cpp/tests/CMakeLists.txt +++ b/fast_pauli/cpp/tests/CMakeLists.txt @@ -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()