-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
59 lines (50 loc) · 1.65 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
set(LIBRARY_NAME robot_model)
find_package(pinocchio REQUIRED)
find_package(OsqpEigen REQUIRED)
set(CORE_SOURCES
src/Model.cpp
)
add_library(${LIBRARY_NAME} SHARED ${CORE_SOURCES})
add_library(${PROJECT_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME})
# add include directories
target_include_directories(${LIBRARY_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${LIBRARY_NAME}
state_representation
${PINOCCHIO_LIBRARIES}
OsqpEigen::OsqpEigen
osqp::osqp
Eigen3::Eigen
)
# install the target and create export-set
install(TARGETS ${LIBRARY_NAME}
EXPORT ${LIBRARY_NAME}_targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# generate and install export file
install(EXPORT ${LIBRARY_NAME}_targets
FILE ${PROJECT_NAME}_${LIBRARY_NAME}_targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
if (BUILD_TESTING)
add_executable(test_${LIBRARY_NAME} test/test_robot_model.cpp)
file(GLOB_RECURSE MODULE_TEST_SOURCES test/tests test_*.cpp)
target_sources(test_${LIBRARY_NAME} PRIVATE ${MODULE_TEST_SOURCES})
target_link_libraries(test_${LIBRARY_NAME}
${LIBRARY_NAME}
${GTEST_LIBRARIES}
pthread
)
target_compile_definitions(test_${LIBRARY_NAME} PRIVATE TEST_FIXTURES="${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures/")
add_test(NAME test_${LIBRARY_NAME} COMMAND test_${LIBRARY_NAME})
endif ()