Skip to content

Commit 365bb9e

Browse files
authored
Change kortex_api header and library install locations (Kinovarobotics#156)
This commit does several two main things: 1) kortex_api now only installs the header files and they now do not pollute include 2) kortex_driver gets the binary libKortexApiCpp.a itself kortex_driver gets the headers from kortex_api this avoids protobuf errors because those header files and the libKortexApiCpp.a were generated using non-system protobuf kortex_api cannot install the libKortexApiCpp.a because CMake does not allow installing library which was IMPORTED This should fix the debian packages which are currently released Signed-off-by: Alex Moriarty <[email protected]>
1 parent 7695711 commit 365bb9e

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ repos:
110110
entry: ament_lint_cmake
111111
language: system
112112
files: CMakeLists\.txt$
113-
exclude: kortex_api/
113+
exclude: '(kortex_api|kortex_driver)/.*'
114114

115115
# Copyright
116116
- repo: local

kortex_api/CMakeLists.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ endif()
3535

3636
find_package(ament_cmake REQUIRED)
3737

38-
ament_export_libraries(${kinova_binary_api_SOURCE_DIR}/lib/release/libKortexApiCpp.a)
39-
link_libraries(pthread)
38+
ament_export_include_directories(include/kortex_api)
4039

41-
ament_export_include_directories(include)
42-
43-
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/client/ DESTINATION include)
44-
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/common/ DESTINATION include)
45-
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/messages/ DESTINATION include)
46-
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/client_stubs/ DESTINATION include)
47-
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/google/protobuf DESTINATION include/google)
40+
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/client/ DESTINATION include/kortex_api)
41+
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/common/ DESTINATION include/kortex_api)
42+
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/messages/ DESTINATION include/kortex_api)
43+
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/client_stubs/ DESTINATION include/kortex_api)
44+
install(DIRECTORY ${kinova_binary_api_SOURCE_DIR}/include/google/protobuf DESTINATION include/kortex_api/google)
4845

4946
ament_package()

kortex_driver/CMakeLists.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.14)
2+
include(FetchContent)
3+
FetchContent_Declare(
4+
kinova_binary_api
5+
URL https://artifactory.kinovaapps.com:443/artifactory/generic-public/kortex/API/2.5.0/linux_x86-64_x86_gcc.zip
6+
URL_HASH MD5=64bd86e7ab8bda90ef1fc7d6a356e080
7+
)
8+
FetchContent_MakeAvailable(kinova_binary_api)
9+
210
project(kortex_driver)
311

412
# Default to C++14
@@ -20,18 +28,40 @@ find_package(pluginlib REQUIRED)
2028
find_package(rclcpp REQUIRED)
2129
find_package(kortex_api REQUIRED)
2230

31+
#Current: only support Linux x86_64
32+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
33+
set(API_URL https://artifactory.kinovaapps.com:443/artifactory/generic-public/kortex/API/2.5.0/linux_x86-64_x86_gcc.zip)
34+
else()
35+
# TODO(future) to support ARM or other builds logic could go here to fetch the precompiled libKortexApiCpp.a
36+
# see notes in kortex_api CMakeList.txt
37+
message(WARNING "Detected ${CMAKE_SYSTEM_NAME} and ${CMAKE_SYSTEM_PROCESSOR}")
38+
message(FATAL_ERROR "Unsupported System: currently support is for Linux x68_64.")
39+
endif()
40+
41+
# CMake does not allow IMPORTED libraries to be installed
42+
# The package kortex_api will download and setup the include directories
43+
add_library(KortexApiCpp STATIC IMPORTED)
44+
set_target_properties(KortexApiCpp PROPERTIES
45+
IMPORTED_LOCATION ${kinova_binary_api_SOURCE_DIR}/lib/release/libKortexApiCpp.a
46+
INTERFACE_LINK_LIBRARIES KortexApiCpp
47+
)
48+
target_link_libraries(KortexApiCpp INTERFACE pthread)
49+
add_dependencies(KortexApiCpp kortex_api)
50+
2351
## COMPILE
2452
add_library(
2553
${PROJECT_NAME}
2654
SHARED
2755
src/hardware_interface.cpp
2856
src/kortex_math_util.cpp
2957
)
58+
target_link_libraries(${PROJECT_NAME} KortexApiCpp)
3059
target_include_directories(
3160
${PROJECT_NAME}
3261
PRIVATE
3362
include
3463
)
64+
# kortex_api is the headers for the Kortex API
3565
ament_target_dependencies(
3666
${PROJECT_NAME}
3767
SYSTEM kortex_api

kortex_driver/include/kortex_driver/hardware_interface.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343

4444
#include "kortex_driver/visibility_control.h"
4545

46-
#include <BaseClientRpc.h>
47-
#include <BaseCyclicClientRpc.h>
48-
#include <RouterClient.h>
49-
#include <SessionManager.h>
50-
#include <TransportClientTcp.h>
51-
#include <TransportClientUdp.h>
46+
#include "BaseClientRpc.h"
47+
#include "BaseCyclicClientRpc.h"
48+
#include "RouterClient.h"
49+
#include "SessionManager.h"
50+
#include "TransportClientTcp.h"
51+
#include "TransportClientUdp.h"
5252

5353
namespace hardware_interface
5454
{

0 commit comments

Comments
 (0)