Skip to content

Commit 4c32f02

Browse files
committed
[tests] Use custom name for nanobind testing target, send it to lib dir
1 parent 0086a1c commit 4c32f02

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tests/CMakeLists.txt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1+
# Create a shared nanobind library for testing
2+
set(NANOBIND_TESTING_TARGET nanobind-testing)
3+
nanobind_build_library(${NANOBIND_TESTING_TARGET} SHARED)
4+
5+
# On Win32, shared DLL libs are sent to RUNTIME_OUTPUT_DIRECTORY, *but*
6+
# we really need to send it to the lib dir so
7+
if(WIN32)
8+
set_target_properties(
9+
${NANOBIND_TESTING_TARGET}
10+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
11+
)
12+
endif()
13+
114
# Add a C++ extension module for tests
215
function(add_tests_cpp_extension name)
316
set(filename ${name}.cpp)
4-
nanobind_add_module(${name} NB_SHARED NB_SUPPRESS_WARNINGS ${filename})
5-
target_link_libraries(${name} PRIVATE nanoeigenpy_headers)
17+
add_library(${name} MODULE ${filename})
18+
target_link_libraries(
19+
${name}
20+
PRIVATE ${NANOBIND_TESTING_TARGET} nanoeigenpy_headers
21+
)
22+
# Use nanobind low-level interface to set properties
23+
nanobind_set_visibility(${name})
24+
nanobind_strip(${name})
25+
nanobind_extension(${name})
26+
nanobind_compile_options(${name})
27+
nanobind_link_options(${name})
28+
629
add_dependencies(build_tests ${name})
730

831
add_test(

0 commit comments

Comments
 (0)