diff --git a/configure.ac b/configure.ac index 35bc2ffb..dd639e13 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 subdir-objects]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_MACRO_DIR([m4]) +AC_PROG_SED PKG_PROG_PKG_CONFIG PKG_INSTALLDIR() diff --git a/lib/EtherCATConfig.cmake.in b/lib/EtherCATConfig.cmake.in new file mode 100644 index 00000000..a803ac0c --- /dev/null +++ b/lib/EtherCATConfig.cmake.in @@ -0,0 +1,49 @@ +#---------------------------------------------------------------------------- +# +# Copyright (C) 2021 Bjarne von Horn, Ingenieurgemeinschaft IgH +# +# This file is part of the IgH EtherCAT Master. +# +# The IgH EtherCAT Master is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. +# +# The IgH EtherCAT Master is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the IgH EtherCAT Master; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# --- +# +# The license mentioned above concerns the source code only. Using the +# EtherCAT technology and brand is only permitted in compliance with the +# industrial property and similar rights of Beckhoff Automation GmbH. +# +# vim: tw=78 +# +#---------------------------------------------------------------------------- + + +find_library(EtherCAT_LIBRARY + NAMES EtherCAT + PATHS %libdir% +) + +find_path(EtherCAT_INCLUDE_DIR + NAMES ecrt.h + PATHS %includedir% +) + +mark_as_advanced(EtherCAT_LIBRARY EtherCAT_INCLUDE_DIR) + +if(NOT TARGET EtherLab::EtherCAT) + add_library(EtherLab::EtherCAT SHARED IMPORTED) + set_target_properties(EtherLab::EtherCAT PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${EtherCAT_INCLUDE_DIR}" + IMPORTED_LOCATION "${EtherCAT_LIBRARY}" + ) +endif() diff --git a/lib/Makefile.am b/lib/Makefile.am index d0cb1bd6..b3f27bc0 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -75,6 +75,10 @@ libethercat_la_LDFLAGS = -version-info 2:0:1 pkgconfig_DATA = libethercat.pc +cmakedir = $(libdir)/cmake + +cmake_DATA = EtherCATConfig.cmake + #------------------------------------------------------------------------------ if ENABLE_RTDM @@ -98,3 +102,8 @@ endif endif #------------------------------------------------------------------------------ + +# we need to replace the variables manually, because autotools does not expand them. + +EtherCATConfig.cmake: $(srcdir)/EtherCATConfig.cmake.in Makefile + $(SED) -e 's,%libdir%,$(libdir),' -e 's,%includedir%,$(includedir),' $< > $@