forked from keivanzavari/rtt_soem
/
patch_for_cmake_soem_core.txt
58 lines (54 loc) · 1.82 KB
/
patch_for_cmake_soem_core.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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b54bd56..59e7a98 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
-project(SOEM C)
+
+# At places where the original CMakeLists is modified,
+# you'll find a small description
+
+# project name changed from SOEM C to lower case to be consistent with catkin
+project(soem)
+
+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Default to installing in SOEM source directory
@@ -44,17 +51,32 @@ file(GLOB SOEM_HEADERS soem/*.h)
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h)
file(GLOB OSHW_HEADERS oshw/${OS}/*.h)
+# How to link static library with cmake in 64bit linux:
+# By enabling Position Independent Code (PIC, with the flag -fPIC)
+# you can ensure the code remains share-able. PIC means that the output binary
+# does not expect to be loaded at a particular base address, but is happy
+# being put anywhere in memory
+# read here:
+# https://www.technovelty.org/c/position-independent-code-and-x86-64-libraries.html
+add_definitions(-fPIC)
+
include_directories(soem)
include_directories(osal)
include_directories(osal/${OS})
include_directories(oshw/${OS})
+# export include and libraries...
+catkin_package(INCLUDE_DIRS soem osal osal/${OS} oshw/${OS}
+ LIBRARIES soem)
+
add_library(soem STATIC
${SOEM_SOURCES}
${OSAL_SOURCES}
${OSHW_SOURCES}
${OSHW_EXTRA_SOURCES})
-target_link_libraries(soem ${OS_LIBS})
+
+# link to catkin libraries
+target_link_libraries(soem ${OS_LIBS} ${catkin_LIBRARIES})
install(TARGETS soem DESTINATION lib)
install(FILES
@@ -66,3 +88,4 @@ install(FILES
add_subdirectory(test/linux/slaveinfo)
add_subdirectory(test/linux/eepromtool)
add_subdirectory(test/linux/simple_test)
+