odroid-mali: new package
[buildroot-gz.git] / package / openpowerlink / 0003-Add-top-level-CMakeLists.txt.patch
blob267c807be07a06b60f49dedd97fa2eb5acbff701
1 From 1b92df6f8283e15b6877f7cd70063648727fc88b Mon Sep 17 00:00:00 2001
2 From: Romain Naour <romain.naour@gmail.com>
3 Date: Wed, 25 May 2016 15:59:20 +0200
4 Subject: [PATCH] Add top level CMakeLists.txt
6 This CMakeLists.txt can be used to build openpowerlink
7 using a automated build system.
9 Don't use FIND_LIBRARY when the stack is built from a top
10 level build (ie CFG_OPLK_LIB is ON).
11 For a top level build, CMake will automatically add a build
12 dependency on oplk libraries for building demos applications.
14 Also replace OPLKLIB_DEBUG by OPLKLIB in OPLK_LINK_LIBRARIES macro
15 if CMAKE_BUILD_TYPE is "Debug", otherwise TARGET_LINK_LIBRARIES can't
16 find the openpowerlink library.
17 This issue may be related to:
18 https://github.com/OpenAutomationTechnologies/openPOWERLINK_V2/issues/109
20 Fixes:
21 http://autobuild.buildroot.net/results/da4/da445b65cb136d71577f04e3a17fdb2ef6302a9b
23 This patch has not been accepted by upstream:
24 https://github.com/openPOWERLINK/openPOWERLINK_V2/pull/57
26 Add PCIe support (v2.3.2)
28 Signed-off-by: Romain Naour <romain.naour@gmail.com>
29 ---
30 CMakeLists.txt | 42 +++++++++++++++++
31 apps/common/cmake/findoplklib.cmake | 68 +++++++++++++++-------------
32 apps/common/cmake/linkoplklib.cmake | 2 +-
33 drivers/linux/drv_daemon_pcap/CMakeLists.txt | 12 +++--
34 4 files changed, 89 insertions(+), 35 deletions(-)
35 create mode 100644 CMakeLists.txt
37 diff --git a/CMakeLists.txt b/CMakeLists.txt
38 new file mode 100644
39 index 0000000..28d4e7a
40 --- /dev/null
41 +++ b/CMakeLists.txt
42 @@ -0,0 +1,42 @@
44 +CMAKE_MINIMUM_REQUIRED (VERSION 2.8.7)
46 +#### LIB ####
48 +IF (CFG_OPLK_LIB)
49 + ADD_SUBDIRECTORY("stack")
50 +ENDIF (CFG_OPLK_LIB)
52 +#### Linux kernel Ethernet module ####
54 +IF (CFG_KERNEL_DRIVERS)
55 + ADD_SUBDIRECTORY("drivers/linux/drv_kernelmod_edrv")
56 +ENDIF (CFG_KERNEL_DRIVERS)
58 +#### Linux kernel PCIe module ####
60 +IF (CFG_KERNEL_PCIE_DRIVERS)
61 + ADD_SUBDIRECTORY("drivers/linux/drv_kernelmod_pcie")
62 +ENDIF (CFG_KERNEL_PCIE_DRIVERS)
64 +#### Pcap userspace driver ####
66 +IF (CFG_PCAP_DAEMON)
67 + ADD_SUBDIRECTORY("drivers/linux/drv_daemon_pcap")
68 +ENDIF (CFG_PCAP_DAEMON)
70 +#### OpenPowerLink Demos ####
72 +# Add subdirectory of CN console demo application
73 +IF (CFG_DEMO_CN_CONSOLE)
74 + ADD_SUBDIRECTORY("apps/demo_cn_console")
75 +ENDIF (CFG_DEMO_CN_CONSOLE)
77 +# Add subdirectory of MN console demo application
78 +IF (CFG_DEMO_MN_CONSOLE)
79 + ADD_SUBDIRECTORY("apps/demo_mn_console")
80 +ENDIF (CFG_DEMO_MN_CONSOLE)
82 +IF (CFG_DEMO_MN_QT)
83 + ADD_SUBDIRECTORY("apps/demo_mn_qt")
84 +ENDIF (CFG_DEMO_MN_QT)
85 diff --git a/apps/common/cmake/findoplklib.cmake b/apps/common/cmake/findoplklib.cmake
86 index aa427a6..e6a802e 100644
87 --- a/apps/common/cmake/findoplklib.cmake
88 +++ b/apps/common/cmake/findoplklib.cmake
89 @@ -89,36 +89,42 @@ MACRO(FIND_OPLK_LIBRARY OPLK_NODE_TYPE)
90 # Set oplk library directory
91 SET(OPLKLIB_DIR ${OPLK_BASE_DIR}/stack/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR})
93 - IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
94 - # Search for release library
95 - UNSET(OPLKLIB CACHE)
96 - MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_NAME} in ${OPLKLIB_DIR}")
97 - FIND_LIBRARY(OPLKLIB NAME ${OPLKLIB_NAME}
98 - HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
100 - IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
102 - UNSET(OPLKDLL CACHE)
103 - FIND_PROGRAM(OPLKDLL NAME ${OPLKLIB_NAME}.dll
104 - HINTS ${OPLKLIB_DIR})
106 - ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
107 - ENDIF()
109 - IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Debug"))
110 - # Search for debug library
111 - UNSET(OPLKLIB_DEBUG CACHE)
112 - MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_DEBUG_NAME} in ${OPLKLIB_DIR}")
113 - FIND_LIBRARY(OPLKLIB_DEBUG NAME ${OPLKLIB_DEBUG_NAME}
114 - HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
116 - IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
118 - UNSET(OPLKDLL_DEBUG CACHE)
119 - FIND_PROGRAM(OPLKDLL_DEBUG NAME ${OPLKLIB_DEBUG_NAME}.dll
120 - HINTS ${OPLKLIB_DIR})
122 - ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
123 - ENDIF()
124 + # Don't look for oplk libraries for a top level build
125 + IF(CFG_OPLK_LIB)
126 + SET(OPLKLIB ${OPLKLIB_NAME})
127 + SET(OPLKLIB_DEBUG ${OPLKLIB_DEBUG_NAME})
128 + ELSE(CFG_OPLK_LIB)
129 + IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
130 + # Search for release library
131 + UNSET(OPLKLIB CACHE)
132 + MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_NAME} in ${OPLKLIB_DIR}")
133 + FIND_LIBRARY(OPLKLIB NAME ${OPLKLIB_NAME}
134 + HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
136 + IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
138 + UNSET(OPLKDLL CACHE)
139 + FIND_PROGRAM(OPLKDLL NAME ${OPLKLIB_NAME}.dll
140 + HINTS ${OPLKLIB_DIR})
142 + ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
143 + ENDIF()
145 + IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Debug"))
146 + # Search for debug library
147 + UNSET(OPLKLIB_DEBUG CACHE)
148 + MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_DEBUG_NAME} in ${OPLKLIB_DIR}")
149 + FIND_LIBRARY(OPLKLIB_DEBUG NAME ${OPLKLIB_DEBUG_NAME}
150 + HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
152 + IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
154 + UNSET(OPLKDLL_DEBUG CACHE)
155 + FIND_PROGRAM(OPLKDLL_DEBUG NAME ${OPLKLIB_DEBUG_NAME}.dll
156 + HINTS ${OPLKLIB_DIR})
158 + ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
159 + ENDIF()
160 + ENDIF(CFG_OPLK_LIB)
162 ENDMACRO(FIND_OPLK_LIBRARY)
163 diff --git a/apps/common/cmake/linkoplklib.cmake b/apps/common/cmake/linkoplklib.cmake
164 index 49aab66..d9fd418 100644
165 --- a/apps/common/cmake/linkoplklib.cmake
166 +++ b/apps/common/cmake/linkoplklib.cmake
167 @@ -33,7 +33,7 @@ MACRO(OPLK_LINK_LIBRARIES EXECUTABLE_NAME)
168 TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} optimized ${OPLKLIB} debug ${OPLKLIB_DEBUG})
169 ELSE()
170 IF(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
171 - TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} debug ${OPLKLIB_DEBUG})
172 + TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} debug ${OPLKLIB})
173 ELSE ()
174 TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} optimized ${OPLKLIB})
175 ENDIF()
176 diff --git a/drivers/linux/drv_daemon_pcap/CMakeLists.txt b/drivers/linux/drv_daemon_pcap/CMakeLists.txt
177 index 2702abd..81bb598 100644
178 --- a/drivers/linux/drv_daemon_pcap/CMakeLists.txt
179 +++ b/drivers/linux/drv_daemon_pcap/CMakeLists.txt
180 @@ -104,9 +104,15 @@ ENDIF()
181 SET(OPLKLIB_DIR ${OPLK_BASE_DIR}/stack/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR})
182 SET(OPLKLIB_INCDIR ${OPLK_BASE_DIR}/stack/proj/${SYSTEM_NAME_DIR}/lib${LIB_NAME})
184 -UNSET(OPLKLIB CACHE)
185 -FIND_LIBRARY(OPLKLIB NAME ${LIB_NAME}${BUILD_TYPE_EXT}
186 - HINTS ${OPLKLIB_DIR})
187 +# Don't look for oplk libraries for a top level build
188 +IF(CFG_OPLK_LIB)
189 + SET(OPLKLIB ${LIB_NAME}${BUILD_TYPE_EXT})
190 +ELSE(CFG_OPLK_LIB)
191 + UNSET(OPLKLIB CACHE)
192 + FIND_LIBRARY(OPLKLIB NAME ${LIB_NAME}${BUILD_TYPE_EXT}
193 + HINTS ${OPLKLIB_DIR})
194 +ENDIF(CFG_OPLK_LIB)
196 INCLUDE_DIRECTORIES(${OPLKLIB_INCDIR})
198 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99 -pthread -fno-strict-aliasing")
200 2.5.5