@@ -12,9 +12,24 @@ execute_process(
1212 COMMAND "${Python_EXECUTABLE} " -m nanobind --cmake_dir
1313 OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR)
1414list (APPEND CMAKE_PREFIX_PATH "${NB_DIR} " )
15+
1516find_package (nanobind CONFIG REQUIRED)
17+ find_package (Threads REQUIRED)
18+
19+ if (MSVC )
20+ # Static link of MSVC rt for optimal compatibility
21+ # It avoids to mess with embedded MSVC rt coming from other packages (see PyQT5)
22+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
23+ # Same, enabling LTO (LTGC for MS) give less ABI compatibility, so we dissable it.
24+ # see https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170
25+ # for more details.
26+ nanobind_add_module(pgeof_ext NOMINSIZE STABLE_ABI src/pgeof_ext.cpp)
27+ else ()
28+ # we enable LTO on Linux and MacOS.
29+ nanobind_add_module(pgeof_ext NOMINSIZE STABLE_ABI LTO src/pgeof_ext.cpp)
30+ endif ()
1631
17- nanobind_add_module (pgeof_ext NOMINSIZE STABLE_ABI LTO src/pgeof_ext.cpp )
32+ target_link_libraries (pgeof_ext PRIVATE Threads::Threads )
1833
1934nanobind_add_stub(
2035 pgeof_ext_stub
@@ -25,10 +40,10 @@ nanobind_add_stub(
2540 DEPENDS pgeof_ext
2641)
2742
28- # All lib are headeer only.
29- # it's faster to include like this than using exported targets
43+ # All lib are header only.
44+ # it's faster to include like this than using exported targets
3045# (i.e add_subdirectories(...))
31- target_include_directories (pgeof_ext PRIVATE "include" "third_party/eigen" "third_party/nanoflann/include" "third_party/taskflow" )
46+ target_include_directories (pgeof_ext PRIVATE "include" "third_party/eigen" "third_party/nanoflann/include" "third_party/taskflow" )
3247
3348install (TARGETS pgeof_ext LIBRARY DESTINATION pgeof)
34- install (FILES ${CMAKE_CURRENT_BINARY_DIR} /pgeof_ext.pyi ${CMAKE_CURRENT_BINARY_DIR} /py.typed DESTINATION pgeof)
49+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /pgeof_ext.pyi ${CMAKE_CURRENT_BINARY_DIR} /py.typed DESTINATION pgeof)
0 commit comments