-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
77 lines (62 loc) · 2.5 KB
/
Copy pathCMakeLists.txt
File metadata and controls
77 lines (62 loc) · 2.5 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
cmake_minimum_required(VERSION 3.02)
project(PyCeres)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Ceres REQUIRED)
find_package(Glog REQUIRED)
find_package(LAPACK)
include_directories(${CERES_INCLUDE_DIR})
# Since we are linking to ceres then we have to access the compile flags used to build it.
add_definitions("-DCERES_IS_LINKED")
add_subdirectory(pybind11)
pybind11_add_module(PyCeres python_bindings/python_module.cpp
python_bindings/ceres_examples_module.cpp
python_bindings/custom_cpp_cost_functions.cpp
# python_bindings/pytorch_cost_function.h
# python_bindings/pytorch_cost_function.cpp
)
find_package(Eigen3 3.3 CONFIG REQUIRED
HINTS ${HOMEBREW_INCLUDE_DIR_HINTS})
if (EIGEN3_FOUND)
message("-- Found Eigen version ${EIGEN3_VERSION_STRING}: ${EIGEN3_INCLUDE_DIRS}")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)" AND
EIGEN3_VERSION_STRING VERSION_LESS 3.3.4)
# As per issue #289: https://github.com/ceres-solver/ceres-solver/issues/289
# the bundle_adjustment_test will fail for Eigen < 3.3.4 on aarch64.
message(FATAL_ERROR "-- Ceres requires Eigen version >= 3.3.4 on aarch64. "
"Detected version of Eigen is: ${EIGEN3_VERSION_STRING}.")
endif()
include_directories(${EIGEN3_INCLUDE_DIR})
endif()
target_link_libraries(PyCeres PRIVATE ${CERES_LIBRARY} ${GLOG_LIBRARY} ${LAPACK_LIBRARIES})
#############
## Install ##
#############
install(
TARGETS PyCeres
EXPORT PyCeresTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install the exported targets
install(
EXPORT PyCeresTargets
FILE PyCeresTargets.cmake
NAMESPACE PyCeres::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PyCeres)
set(PyCeres_BUILDDIR "${CMAKE_BINARY_DIR}/PyCeres")
# For the python package we need an init file
file(
GENERATE
OUTPUT "${PyCeres_BUILDDIR}/__init__.py"
CONTENT "from PyCeres.PyCeres import *\n")
# Install the __init__.py file
install(
FILES "${PyCeres_BUILDDIR}/__init__.py"
DESTINATION ${CMAKE_INSTALL_PREFIX})
#install(
# TARGETS pybind11_bindings
# COMPONENT bindings
# LIBRARY DESTINATION ${MYMATH_INSTALL_PREFIX}
# ARCHIVE DESTINATION ${MYMATH_INSTALL_PREFIX}
# RUNTIME DESTINATION ${MYMATH_INSTALL_PREFIX})