-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
93 lines (76 loc) · 3.5 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS_INIT} -Wall -fPIC")
add_subdirectory("urdf_parser")
include_directories("third_party" "urdf_parser/include")
find_package(Eigen3 REQUIRED)
ADD_DEFINITIONS(-DEIGEN_NO_DEBUG)
include_directories(${EIGEN3_INCLUDE_DIR})
set(TINYFK_SRC src/tinyfk.cpp src/kinematics.cpp)
include_directories(include/)
add_library(tinyfk STATIC ${TINYFK_SRC})
target_link_libraries(tinyfk urdfdom_model)
# testing
option(BUILD_TEST "build google test" OFF)
if(BUILD_TEST)
find_package(GTest REQUIRED)
function(setup_tinyfk_test test_name test_src)
add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} tinyfk ${GTEST_LIBRARIES} pthread)
target_include_directories(${test_name} PUBLIC ${GTEST_INCLUDE_DIRS})
endfunction()
setup_tinyfk_test(test_others test/test_others.cpp)
setup_tinyfk_test(test_data_structure test/test_data_structure.cpp)
setup_tinyfk_test(test_kinematics test/test_kinematics.cpp)
setup_tinyfk_test(test_parse test/test_parse.cpp)
set(nlohmann_json_INCLUDE_DIRS third_party/json/include)
target_include_directories(test_kinematics PUBLIC ${nlohmann_json_INCLUDE_DIRS})
enable_testing()
gtest_discover_tests(test_data_structure)
gtest_discover_tests(test_kinematics)
gtest_discover_tests(test_parse)
endif(BUILD_TEST)
# benchmark (kdl)
option(BENCH_KDL "benchmarking kdl" OFF)
if(BENCH_KDL)
find_package(orocos_kdl REQUIRED)
message(${orocos_kdl_INCLUDE_DIRS})
add_library(kdl_parser STATIC bench/kdl_parser/kdl_parser.cpp)
target_link_libraries(kdl_parser ${orocos_kdl_LIBRARIES})
target_include_directories(kdl_parser PUBLIC ${orocos_kdl_INCLUDE_DIRS} bench/kdl_parser)
add_executable(bench_kdl bench/bench_kdl.cpp)
target_link_libraries(bench_kdl urdfdom_model ${orocos_kdl_LIBRARIES} kdl_parser)
target_include_directories(bench_kdl PUBLIC ${orocos_kdl_INCLUDE_DIRS} bench/kdl_parser)
endif(BENCH_KDL)
# benchmark (tinyfk)
add_executable(bench_tinyfk bench/bench_tinyfk.cpp)
target_link_libraries(bench_tinyfk tinyfk)
option(BUILD_PYTHON_INTERFACE "Set when you want to build python interface" ON)
if(BUILD_PYTHON_INTERFACE)
option(INSTALL_VIA_PIP "if you install via pip install . " ON)
set(LIBRARY_NAME _tinyfk)
add_subdirectory(third_party/pybind11)
pybind11_add_module(_tinyfk src/wrapper.cpp)
target_link_libraries(_tinyfk PRIVATE tinyfk)
if(INSTALL_VIA_PIP)
install(TARGETS _tinyfk DESTINATION .) # for pip install
else() # gdb friendly.
option(PYTHON_GLOBAL_SITE_PKG
"install into global site package. if OFF, or by default, will be installed into per-user site-packages"
OFF)
if(PYTHON_GLOBAL_SITE_PKG)
set(CMD_SITE_PKG "import site; import sys;sys.stdout.write(site.getsitepackages()[0])")
else(PYTHON_GLOBAL_SITE_PKG)
set(CMD_SITE_PKG "import site; import sys;sys.stdout.write(site.getusersitepackages())")
endif(PYTHON_GLOBAL_SITE_PKG)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "${CMD_SITE_PKG}"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
)
install(TARGETS _tinyfk DESTINATION ${PYTHON_SITE_PACKAGES_INSTALL_DIR})
message("destination site-packages:" ${PYTHON_SITE_PACKAGES_INSTALL_DIR})
endif()
endif(BUILD_PYTHON_INTERFACE)