-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (47 loc) · 1.69 KB
/
Copy pathCMakeLists.txt
File metadata and controls
59 lines (47 loc) · 1.69 KB
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
50
51
52
53
54
55
56
57
58
59
cmake_minimum_required(VERSION 3.15...3.26)
project(nanobind_project LANGUAGES CXX)
# find_package(OpenMP REQUIRED)
# Try to import all Python components potentially needed by nanobind
find_package(Python 3.10
REQUIRED COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
# Import nanobind through CMake's find_package mechanism
find_package(nanobind CONFIG REQUIRED)
nanobind_add_module(
# Name of the extension
_tetgen
# Target the stable ABI for Python 3.12+, which reduces
# the number of binary wheels that must be built. This
# does nothing on older Python versions
STABLE_ABI
# conserve space by reusing a shared libnanobind across libraries (necessary here?)
NB_STATIC
src/tetgen.cxx # Core src from tetgen
src/predicates.cxx # Supporting src from tetgen
src/_tetgen.cpp # nanobind interface to tetgen.cxx
)
# Link OpenMP
# if(OpenMP_CXX_FOUND)
# target_link_libraries(_tetgen PRIVATE OpenMP::OpenMP_CXX)
# endif()
# Compiler-specific options
if(MSVC)
# Use MSVC optimization levels and OpenMP setup
target_compile_options(_tetgen PRIVATE /O2 /std:c++17)
# /openmp:llvm
else()
# Assuming GCC or Clang
target_compile_options(_tetgen PRIVATE
-O3
-fno-expensive-optimizations # causes severe issues on ARM
)
# -fopenmp
endif()
target_compile_definitions(_tetgen PRIVATE TETLIBRARY)
# Example debugging
# set solib-search-path /home/user/python/.venv311/lib/python3.11/site-packages/tetgen/
# set breakpoint with b qual.cpp:4872
# target_compile_options(tetgen PRIVATE -g -O0)
# target_compile_options(pfh PRIVATE -g -O0)
# Install directive for scikit-build-core
install(TARGETS _tetgen LIBRARY DESTINATION tetgen)