kumquat-buildroot/package/openpowerlink/0005-Add-top-level-CMakeLists.txt.patch
Romain Naour b1063a0136 package/openpowerlink: bump to v2.2.2
From [1]:
With version 2.0, the source code has been cleanly split into
an application-oriented user library and a time-critical stack
driver. The latter may be moved to a dedicated communication
processor or into a kernel module to deliver enhanced
performance while still keeping the API in user space.

This new version break the API used in the v1.x but
this is a complete rewrite of the Powerlink EPSG DS 301
implementation. The v1.x is deprecated anyway.

The new build system has been split in several CMake projects
which makes it difficult to package with the Buildroot CMake
infra. So add a top level CMakeLists.txt to build each
openpowerlink component without having to package each of them
in a separate Buildroot packages. Also we need to fix the
build system to support the top level CMake build.

[1] http://sourceforge.net/projects/openpowerlink/

Signed-off-by: Romain Naour <romain.naour@gmail.com>

[Thomas:
 - rename patches to not contain the [FIX] part in their title.
 - rewrap Config.in help text
 - rename "openPOWERLINK stack type" to "stack type"
 - rename ""openpowerlink demos" to "demos"]

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-02-07 19:04:02 +01:00

171 lines
6.3 KiB
Diff

From 5cf3f37e12d0bb4649e3cda29a43d748708aa554 Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@openwide.fr>
Date: Wed, 12 Aug 2015 11:24:24 +0200
Subject: [PATCH] Add top level CMakeLists.txt
This CMakeLists.txt can be used to build openpowerlink
using a automated build system.
Don't use FIND_LIBRARY when the stack is built from a top
level build (ie CFG_OPLK_LIB is ON).
For a top level build, CMake will automatically add a build
dependency on oplk libraries for building demos applications.
This patch has been submitted upstream:
https://github.com/openPOWERLINK/openPOWERLINK_V2/pull/57
Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
CMakeLists.txt | 36 +++++++++++++++
apps/common/cmake/findoplklib.cmake | 68 +++++++++++++++-------------
drivers/linux/drv_daemon_pcap/CMakeLists.txt | 12 +++--
3 files changed, 82 insertions(+), 34 deletions(-)
create mode 100644 CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..96e3d0f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,36 @@
+
+CMAKE_MINIMUM_REQUIRED (VERSION 2.8.7)
+
+#### LIB ####
+
+IF (CFG_OPLK_LIB)
+ ADD_SUBDIRECTORY("stack")
+ENDIF (CFG_OPLK_LIB)
+
+#### Linux kernel module ####
+
+IF (CFG_KERNEL_DRIVERS)
+ ADD_SUBDIRECTORY("drivers/linux/drv_kernelmod_edrv")
+ENDIF (CFG_KERNEL_DRIVERS)
+
+#### Pcap userspace driver ####
+
+IF (CFG_PCAP_DAEMON)
+ ADD_SUBDIRECTORY("drivers/linux/drv_daemon_pcap")
+ENDIF (CFG_PCAP_DAEMON)
+
+#### OpenPowerLink Demos ####
+
+# Add subdirectory of CN console demo application
+IF (CFG_DEMO_CN_CONSOLE)
+ ADD_SUBDIRECTORY("apps/demo_cn_console")
+ENDIF (CFG_DEMO_CN_CONSOLE)
+
+# Add subdirectory of MN console demo application
+IF (CFG_DEMO_MN_CONSOLE)
+ ADD_SUBDIRECTORY("apps/demo_mn_console")
+ENDIF (CFG_DEMO_MN_CONSOLE)
+
+IF (CFG_DEMO_MN_QT)
+ ADD_SUBDIRECTORY("apps/demo_mn_qt")
+ENDIF (CFG_DEMO_MN_QT)
diff --git a/apps/common/cmake/findoplklib.cmake b/apps/common/cmake/findoplklib.cmake
index 1bf570e..79ea35b 100644
--- a/apps/common/cmake/findoplklib.cmake
+++ b/apps/common/cmake/findoplklib.cmake
@@ -81,36 +81,42 @@ MACRO(FIND_OPLK_LIBRARY OPLK_NODE_TYPE)
# Set oplk library directory
SET(OPLKLIB_DIR ${OPLK_BASE_DIR}/stack/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR})
- IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
- # Search for release library
- UNSET(OPLKLIB CACHE)
- MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_NAME} in ${OPLKLIB_DIR}")
- FIND_LIBRARY(OPLKLIB NAME ${OPLKLIB_NAME}
- HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
-
- IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
-
- UNSET(OPLKDLL CACHE)
- FIND_PROGRAM(OPLKDLL NAME ${OPLKLIB_NAME}.dll
- HINTS ${OPLKLIB_DIR})
-
- ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- ENDIF()
-
- IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Debug"))
- # Search for debug library
- UNSET(OPLKLIB_DEBUG CACHE)
- MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_DEBUG_NAME} in ${OPLKLIB_DIR}")
- FIND_LIBRARY(OPLKLIB_DEBUG NAME ${OPLKLIB_DEBUG_NAME}
- HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
-
- IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
-
- UNSET(OPLKDLL_DEBUG CACHE)
- FIND_PROGRAM(OPLKDLL_DEBUG NAME ${OPLKLIB_DEBUG_NAME}.dll
- HINTS ${OPLKLIB_DIR})
-
- ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- ENDIF()
+ # Don't look for oplk libraries for a top level build
+ IF(CFG_OPLK_LIB)
+ SET(OPLKLIB ${OPLKLIB_NAME})
+ SET(OPLKLIB_DEBUG ${OPLKLIB_DEBUG_NAME})
+ ELSE(CFG_OPLK_LIB)
+ IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
+ # Search for release library
+ UNSET(OPLKLIB CACHE)
+ MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_NAME} in ${OPLKLIB_DIR}")
+ FIND_LIBRARY(OPLKLIB NAME ${OPLKLIB_NAME}
+ HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
+
+ IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+
+ UNSET(OPLKDLL CACHE)
+ FIND_PROGRAM(OPLKDLL NAME ${OPLKLIB_NAME}.dll
+ HINTS ${OPLKLIB_DIR})
+
+ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ ENDIF()
+
+ IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Debug"))
+ # Search for debug library
+ UNSET(OPLKLIB_DEBUG CACHE)
+ MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_DEBUG_NAME} in ${OPLKLIB_DIR}")
+ FIND_LIBRARY(OPLKLIB_DEBUG NAME ${OPLKLIB_DEBUG_NAME}
+ HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
+
+ IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+
+ UNSET(OPLKDLL_DEBUG CACHE)
+ FIND_PROGRAM(OPLKDLL_DEBUG NAME ${OPLKLIB_DEBUG_NAME}.dll
+ HINTS ${OPLKLIB_DIR})
+
+ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ ENDIF()
+ ENDIF(CFG_OPLK_LIB)
ENDMACRO(FIND_OPLK_LIBRARY)
diff --git a/drivers/linux/drv_daemon_pcap/CMakeLists.txt b/drivers/linux/drv_daemon_pcap/CMakeLists.txt
index 2702abd..81bb598 100644
--- a/drivers/linux/drv_daemon_pcap/CMakeLists.txt
+++ b/drivers/linux/drv_daemon_pcap/CMakeLists.txt
@@ -104,9 +104,15 @@ ENDIF()
SET(OPLKLIB_DIR ${OPLK_BASE_DIR}/stack/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR})
SET(OPLKLIB_INCDIR ${OPLK_BASE_DIR}/stack/proj/${SYSTEM_NAME_DIR}/lib${LIB_NAME})
-UNSET(OPLKLIB CACHE)
-FIND_LIBRARY(OPLKLIB NAME ${LIB_NAME}${BUILD_TYPE_EXT}
- HINTS ${OPLKLIB_DIR})
+# Don't look for oplk libraries for a top level build
+IF(CFG_OPLK_LIB)
+ SET(OPLKLIB ${LIB_NAME}${BUILD_TYPE_EXT})
+ELSE(CFG_OPLK_LIB)
+ UNSET(OPLKLIB CACHE)
+ FIND_LIBRARY(OPLKLIB NAME ${LIB_NAME}${BUILD_TYPE_EXT}
+ HINTS ${OPLKLIB_DIR})
+ENDIF(CFG_OPLK_LIB)
+
INCLUDE_DIRECTORIES(${OPLKLIB_INCDIR})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99 -pthread -fno-strict-aliasing")
--
2.4.3