-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
49 lines (41 loc) · 1.93 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cmake_minimum_required(VERSION 3.15...3.27)
project(pgeof)
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Detect the installed nanobind package and import it into CMake
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR)
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
find_package(nanobind CONFIG REQUIRED)
find_package(Threads REQUIRED)
if(MSVC)
# Static link of MSVC rt for optimal compatibility
# It avoids to mess with embedded MSVC rt coming from other packages (see PyQT5)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# Same, enabling LTO (LTGC for MS) give less ABI compatibility, so we dissable it.
# see https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170
# for more details.
nanobind_add_module(pgeof_ext NOMINSIZE STABLE_ABI src/pgeof_ext.cpp)
else()
# we enable LTO on Linux and MacOS.
nanobind_add_module(pgeof_ext NOMINSIZE STABLE_ABI LTO src/pgeof_ext.cpp)
endif()
target_link_libraries(pgeof_ext PRIVATE Threads::Threads)
nanobind_add_stub(
pgeof_ext_stub
MODULE pgeof_ext
OUTPUT pgeof_ext.pyi
MARKER_FILE py.typed
PYTHON_PATH $<TARGET_FILE_DIR:pgeof_ext>
DEPENDS pgeof_ext
)
# All lib are header only.
# it's faster to include like this than using exported targets
# (i.e add_subdirectories(...))
target_include_directories(pgeof_ext PRIVATE "include" "third_party/eigen" "third_party/nanoflann/include" "third_party/taskflow")
install(TARGETS pgeof_ext LIBRARY DESTINATION pgeof)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pgeof_ext.pyi ${CMAKE_CURRENT_BINARY_DIR}/py.typed DESTINATION pgeof)