-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
120 lines (93 loc) · 3.52 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
cmake_minimum_required(VERSION 3.0.2)
project(akd_ethercat_lib)
# Check to make sure submodule was initialized.
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/AKD-Ethercat-Master/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
)
## Generate messages in the 'msg' folder
add_message_files(
DIRECTORY msg
FILES
akd_fixedPDO_1725.msg
akd_fixedPDO_1B20.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
# Workaround for cmake complaining about missing include directory
file(MAKE_DIRECTORY ${CATKIN_DEVEL_PREFIX}/include)
# Workaround for catkin_lint complaining about external include directory
list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${CATKIN_DEVEL_PREFIX}/include)
catkin_package(
CATKIN_DEPENDS message_runtime
LIBRARIES AKD_ecat soem
)
###########
## Build ##
###########
include(ExternalProject)
ExternalProject_Add( AKD_lib
BUILD_ALWAYS 1
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AKD-Ethercat-Master
CMAKE_ARGS #-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}
-DCMAKE_INSTALL_PREFIX=${CATKIN_DEVEL_PREFIX}
)
add_library(AKD_ecat INTERFACE)
target_include_directories(AKD_ecat SYSTEM INTERFACE ${CATKIN_DEVEL_PREFIX}/include )
target_link_libraries(AKD_ecat INTERFACE ${CATKIN_DEVEL_PREFIX}/lib/libAKD_ecat.a)
add_dependencies(AKD_ecat AKD_lib)
add_library(soem INTERFACE)
target_include_directories(soem SYSTEM INTERFACE ${CATKIN_DEVEL_PREFIX}/include/soem )
target_link_libraries(soem INTERFACE ${CATKIN_DEVEL_PREFIX}/lib/libsoem.a)
add_dependencies(soem AKD_lib)
#############
## Install ##
#############
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
install(FILES ${CATKIN_DEVEL_PREFIX}/lib/libAKD_ecat.a ${CATKIN_DEVEL_PREFIX}/lib/libsoem.a
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
#Mark cpp header files for installation
install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/include/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)
#install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/share/
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
#)
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_akd_ethercat_lib.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)