Skip to content

Commit

Permalink
Merge branch 'master' of github.com:robert-burger/libethercat
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-burger committed Mar 4, 2024
2 parents 6741ff9 + 4096b57 commit d9c124b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckLibraryExists)
include(ExternalProject)
include(CMakePackageConfigHelpers)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
Expand Down Expand Up @@ -115,3 +116,34 @@ target_link_libraries (ethercatdiag ethercat ${libosal_LIBS})
add_executable(example_with_dc tools/example_with_dc/example_with_dc.c)
target_link_libraries (example_with_dc ethercat ${libosal_LIBS} m)

# Install
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/libethercatConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

set(INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
set(ETHERCAT_LIB_NAME ethercat)

configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/libethercatConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/libethercatConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/libethercat
PATH_VARS ETHERCAT_LIB_NAME INSTALL_DIR
)

install(TARGETS ethercat EXPORT libethercatTargets)
install(
EXPORT libethercatTargets
FILE libethercatTargets.cmake
DESTINATION lib/cmake/libethercat
)
install(DIRECTORY include/libethercat/ DESTINATION include/libethercat
FILES_MATCHING PATTERN "*.h"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libethercatConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/libethercatConfigVersion.cmake"
DESTINATION lib/cmake/libethercat
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This library provides all functionality to communicate with EtherCAT slaves atta

# Network device access

- **raw socket** » The most common way sending ethernet frames in Linux is opening a raw network socket (`SOCK_RAW`). Therefor the program must either be run as root or with the capability flag `CAP_NET_RAW`.
- **raw socket** » The most common way sending ethernet frames in Linux is opening a raw network socket (`SOCK_RAW`). Therefor the program must either be run as root or with the capability flag `CAP_NET_RAW`. Either do sth like: `sudo setcap cap_net_raw=ep .libs/example_with_dc` or checkout grant_cap_net_raw kernel module from Flo Schmidt (https://gitlab.com/fastflo/open_ethercat).
- **raw_socket_mmaped** » Like above but don't use read/write to provide frame buffers to kernel and use mmaped buffers directly from kernel.
- **file** » Most performant/determinstic interface to send/receive frames with network hardware. Requires hacked linux network driver. Can also be used without interrupts to avoid context switches. For how to compile and use such a driver head over to [drivers readme](linux/README.md).
- **pikeos** » Special pikeos hardware access.
Expand Down
34 changes: 34 additions & 0 deletions cmake/libethercatConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ===================================================================================
# @PROJECT_NAME@ CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# FIND_PACKAGE(@PROJECT_NAME@ REQUIRED )
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${@PROJECT_NAME@_LIBS})
#
# This file will define the following variables:
# - @PROJECT_NAME@_LIBS : The list of libraries to links against.
# - @PROJECT_NAME@_LIB_DIR : The directory where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - @PROJECT_NAME@_VERSION : The version of this PROJECT_NAME build. Example: "1.2.0"
# - @PROJECT_NAME@_VERSION_MAJOR : Major version part of VERSION. Example: "1"
# - @PROJECT_NAME@_VERSION_MINOR : Minor version part of VERSION. Example: "2"
# - @PROJECT_NAME@_VERSION_PATCH : Patch version part of VERSION. Example: "0"
#
# ===================================================================================
@PACKAGE_INIT@
INCLUDE_DIRECTORIES("@PACKAGE_INSTALL_DIR@/include")
SET(@PROJECT_NAME@_INCLUDE_DIRS "@PACKAGE_INSTALL_DIR@/include")

LINK_DIRECTORIES("@PACKAGE_INSTALL_DIR@/lib")
SET(@PROJECT_NAME@_LIB_DIR "@PACKAGE_INSTALL_DIR@/lib")

SET(@PROJECT_NAME@_LIBS @REQUIRED_LIBRARIES@ @ETHERCAT_LIB_NAME@@PROJECT_DLLVERSION@)
SET(@PROJECT_NAME@_FOUND YES)
SET(@PROJECT_NAME@_VERSION @PROJECT_VERSION@)
SET(@PROJECT_NAME@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@)
SET(@PROJECT_NAME@_VERSION_MINOR @PROJECT_VERSION_MINOR@)
SET(@PROJECT_NAME@_VERSION_PATCH @PROJECT_VERSION_PATCH@)

0 comments on commit d9c124b

Please sign in to comment.