-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
147 lines (119 loc) · 6.12 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
PROJECT(roboy_controlled_node_fpga C CXX)
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.7)
# Set CMake Policy to suppress the warning in CMake version 3.3.x
IF (POLICY CMP0043)
CMAKE_POLICY(SET CMP0043 OLD)
ENDIF()
if(NOT EXISTS "ENV{SOCEDS_DEST_ROOT}")
message(STATUS "cross compiling for arm")
# we are cross compiling for arm (make sure to be in embedded_command_shell.sh)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(compiler_path /usr/bin)
set(CMAKE_C_COMPILER ${compiler_path}/arm-linux-gnueabihf-gcc-5)
set(CMAKE_CXX_COMPILER ${compiler_path}/arm-linux-gnueabihf-g++-5)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/options.cmake)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0 -g")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
################################################################################
# Setup project files and definitions
SET(OBJDICT CiA401_CN) # Set object dictionary to use
FIND_OPLK_LIBRARY("cn") # Find suitable openPOWERLINK library
# ros
find_package(catkin REQUIRED COMPONENTS common_utilities roboy_communication_middleware std_msgs)
include(findros)
include_directories(${catkin_INCLUDE_DIRS} )
catkin_package( CATKIN_DEPENDS message_runtime common_utilities roboy_communication_middleware)
include_directories(include/roboy_controlled_node_fpga
usr/include/arm-linux-gnueabihf
)
# Set generic sources and include directories for this demo
SET(SOURCE
src/main.cpp
src/myoSlave.cpp
${CONTRIB_SOURCE_DIR}/console/printlog.c
${CONTRIB_SOURCE_DIR}/getopt/getopt.c
${COMMON_SOURCE_DIR}/eventlog/eventlog.c
${COMMON_SOURCE_DIR}/eventlog/eventlogstring.c
${COMMON_SOURCE_DIR}/obdcreate/obdcreate.c
)
include(findncurses_arm)
include(findpcap)
SET(ALT_DEVICE_FAMILY soc_cv_av)
add_definitions(-D${ALT_DEVICE_FAMILY})
MESSAGE(STATUS "fpga include dir: $ENV{SOCEDS_DEST_ROOT}/ip/altera/hps/altera_hps/hwlib/${ALT_DEVICE_FAMILY}")
MESSAGE(STATUS "objectdic dir: ${OPLK_BASE_DIR}/apps/common/objdicts/${OBJDICT}")
INCLUDE_DIRECTORIES(
include/
$ENV{SOCEDS_DEST_ROOT}/ip/altera/hps/altera_hps/hwlib/${ALT_DEVICE_FAMILY}
$ENV{SOCEDS_DEST_ROOT}/ip/altera/hps/altera_hps/hwlib/include
$ENV{SOCEDS_DEST_ROOT}/ip/altera/hps/altera_hps/hwlib/include/${ALT_DEVICE_FAMILY}
${CMAKE_CURRENT_SOURCE_DIR}/../roboy_powerlink/powerlink/output
# ${CMAKE_CURRENT_SOURCE_DIR}/../roboy_powerlink/Demo_3CN/output
${OPLK_BASE_DIR}/stack/proj/linux/liboplkmndrv-pcap
)
# PResChaining is not supported by non-openMAC targets
#ADD_DEFINITIONS(-DCONFIG_DLL_PRES_CHAINING_CN)
ADD_DEFINITIONS(-DNMT_MAX_NODE_ID=0)
ADD_DEFINITIONS(-DCONFIG_INCLUDE_PDO)
ADD_DEFINITIONS(-DCONFIG_INCLUDE_SDO_ASND)
ADD_DEFINITIONS(-DCONFIG_INCLUDE_MASND)
IF(CFG_IP_STACK)
ADD_DEFINITIONS(-DCONFIG_INCLUDE_IP)
ADD_DEFINITIONS(-DCONFIG_INCLUDE_SDO_UDP)
ENDIF(CFG_IP_STACK)
IF(CFG_STORE_RESTORE)
ADD_DEFINITIONS(-DCONFIG_OBD_USE_STORE_RESTORE)
ENDIF(CFG_STORE_RESTORE)
################################################################################
# Setup compile definitions depending on configuration
# PCAP is used for directlink of userspace daemon
IF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON)
ADD_DEFINITIONS(-DCONFIG_USE_PCAP)
SET (SOURCE ${SOURCE} ${COMMON_SOURCE_DIR}/pcap/pcap-console.c)
ENDIF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON)
# Setup compile definitions depending on configuration
IF (CFG_KERNEL_STACK_DIRECTLINK)
UNSET (CFG_DEMO_CN_CONSOLE_USE_SYNCTHREAD CACHE)
ADD_DEFINITIONS(-DCONFIG_KERNELSTACK_DIRECTLINK)
ELSE (CFG_KERNEL_STACK_DIRECTLINK)
OPTION (CFG_DEMO_CN_CONSOLE_USE_SYNCTHREAD "Create separate thread for syncronous data exchange" ON)
IF (CFG_DEMO_CN_CONSOLE_USE_SYNCTHREAD)
ADD_DEFINITIONS(-DCONFIG_USE_SYNCTHREAD)
ENDIF (CFG_DEMO_CN_CONSOLE_USE_SYNCTHREAD)
ENDIF (CFG_KERNEL_STACK_DIRECTLINK)
################################################################################
# Setup the architecture specific definitions
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(linux.cmake)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include (windows.cmake)
ELSE()
MESSAGE(FATAL_ERROR "System ${CMAKE_SYSTEM_NAME} is not supported!")
ENDIF()
################################################################################
################################################################################
# Set the executable
ADD_EXECUTABLE(roboy_controlled_node_fpga ${SOURCE} src/i2c.cpp src/am4096.cpp ${DEMO_ARCH_SOURCES} )
SET_PROPERTY(TARGET roboy_controlled_node_fpga
PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG;DEF_DEBUG_LVL=${CFG_DEBUG_LVL})
OPLK_LINK_LIBRARIES(roboy_controlled_node_fpga)
add_dependencies(roboy_controlled_node_fpga roboy_communication_middleware_gencpp)
TARGET_LINK_LIBRARIES(roboy_controlled_node_fpga ${pcap_LIBRARY} ${pcap_udp_LIBRARY} -lpthread -lrt ${ros_LIBRARIES})#
ADD_EXECUTABLE(roboy_commandline_interface src/i2c.cpp src/am4096.cpp src/myoControl.cpp src/interface.cpp )
TARGET_LINK_LIBRARIES(roboy_commandline_interface ${ncurses_LIBRARIES} ${ros_LIBRARIES} )
#==============================================================================
# Installation
#==============================================================================
install(TARGETS
roboy_controlled_node_fpga
roboy_commandline_interface
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
else()
message(STATUS "cannot cross compile, are you in an embedded_command_shell.sh?!")
endif()