-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
49 lines (42 loc) · 2.49 KB
/
Copy pathCMakeLists.txt
File metadata and controls
49 lines (42 loc) · 2.49 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
cmake_minimum_required(VERSION 3.18)
project(evkit LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(EVKIT_CXX_FLAGS -O3 -march=native -funroll-loops -ffast-math)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
# Resolve torch include and library paths via the official torch helper. This
# matches what `setup.py` with `torch.utils.cpp_extension.CppExtension` uses
# and handles the conda libtorch + python torch coexistence cleanly.
execute_process(
COMMAND ${Python_EXECUTABLE} -c "from torch.utils.cpp_extension import include_paths; print(';'.join(include_paths()))"
OUTPUT_VARIABLE TORCH_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python_EXECUTABLE} -c "from torch.utils.cpp_extension import library_paths; print(';'.join(library_paths()))"
OUTPUT_VARIABLE TORCH_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# ---- evkit._kernels.representations.voxel_grid (merged + split; production) --
pybind11_add_module(voxel_grid evkit/_kernels/representations/voxel_grid.cpp)
target_compile_options(voxel_grid PRIVATE ${EVKIT_CXX_FLAGS})
target_include_directories(voxel_grid PRIVATE ${TORCH_INCLUDE_DIRS})
target_link_directories(voxel_grid PRIVATE ${TORCH_LIBRARY_DIRS})
target_link_libraries(voxel_grid PRIVATE torch torch_cpu c10 torch_python)
install(TARGETS voxel_grid DESTINATION evkit/_kernels/representations)
# ---- evkit._kernels.representations.time_surface (merged + split; production) -
pybind11_add_module(time_surface evkit/_kernels/representations/time_surface.cpp)
target_compile_options(time_surface PRIVATE ${EVKIT_CXX_FLAGS})
target_include_directories(time_surface PRIVATE ${TORCH_INCLUDE_DIRS})
target_link_directories(time_surface PRIVATE ${TORCH_LIBRARY_DIRS})
target_link_libraries(time_surface PRIVATE torch torch_cpu c10 torch_python)
install(TARGETS time_surface DESTINATION evkit/_kernels/representations)
# ---- evkit._kernels.representations.count_frame (sep/sum/diff; production) -----
pybind11_add_module(count_frame evkit/_kernels/representations/count_frame.cpp)
target_compile_options(count_frame PRIVATE ${EVKIT_CXX_FLAGS})
target_include_directories(count_frame PRIVATE ${TORCH_INCLUDE_DIRS})
target_link_directories(count_frame PRIVATE ${TORCH_LIBRARY_DIRS})
target_link_libraries(count_frame PRIVATE torch torch_cpu c10 torch_python)
install(TARGETS count_frame DESTINATION evkit/_kernels/representations)