-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
47 lines (37 loc) · 1.32 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
cmake_minimum_required(VERSION 3.5)
project(cTrack)
if (BUILD_LIBTORCH)
if(APPLE)
message(FATAL_ERROR "Cannot build libtorch on macs")
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import torch; print(torch.utils.cmake_prefix_path)"
RESULT_VARIABLE result
OUTPUT_VARIABLE CMAKE_PREFIX_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir2}")
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -fopenmp -O3")
else()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3")
endif()
endif()
if(SKBUILD)
execute_process(
COMMAND
python3 -c
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(PREPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
find_package(pybind11 CONFIG REQUIRED)
endif()
pybind11_add_module(cTrack MODULE SYRIPY/Tracking/cTrack/Bindings.cpp
SYRIPY/Tracking/cTrack/Field.cpp SYRIPY/Tracking/cTrack/Track.cpp )
if (BUILD_LIBTORCH)
target_link_libraries(cTrack PRIVATE ${Python_LIBRARIES} ${TORCH_LIBRARIES})
target_compile_definitions(cTrack PRIVATE USE_TORCH=1)
endif()
install(TARGETS cTrack LIBRARY DESTINATION .)