Skip to content

Commit

Permalink
Fixed bugs for installing on macs and other systems
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiewatt1 committed Feb 22, 2024
1 parent 22cb653 commit c839972
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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
Expand All @@ -12,7 +15,11 @@ if (BUILD_LIBTORCH)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -fopenmp -O3")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3")
endif()
endif()


Expand All @@ -23,7 +30,7 @@ if(SKBUILD)
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
list(PREPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
find_package(pybind11 CONFIG REQUIRED)
endif()

Expand All @@ -32,9 +39,9 @@ endif()
pybind11_add_module(cTrack MODULE SYRIPY/Tracking/cTrack/Bindings.cpp
SYRIPY/Tracking/cTrack/Field.cpp SYRIPY/Tracking/cTrack/Track.cpp )

if (BUILD_LIBTORCH)
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 .)
install(TARGETS cTrack LIBRARY DESTINATION .)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[build-system]
requires = [
"pybind11>=2.10",
"setuptools",
"wheel",
"pybind11",
"cmake",
"scikit-build",
"torch"
]
]
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ def set_cmake_args():
install_requires=[
'numpy',
'matplotlib',
'torch'
],
)
'torch'])

0 comments on commit c839972

Please sign in to comment.