From 9d484de82a0c5de6cf9161f626fbe650ca0eb532 Mon Sep 17 00:00:00 2001 From: Bjarne von Horn Date: Sat, 1 Jan 2022 23:41:23 +0100 Subject: [PATCH 1/2] Fix cmake config module --- lib/Makefile.am | 8 ++++---- lib/{EtherCATConfig.cmake.in => ethercat-config.cmake.in} | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) rename lib/{EtherCATConfig.cmake.in => ethercat-config.cmake.in} (90%) diff --git a/lib/Makefile.am b/lib/Makefile.am index 4d9879ed..330c1e34 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -75,11 +75,11 @@ libethercat_la_LDFLAGS = -version-info 2:0:1 pkgconfig_DATA = libethercat.pc -cmakedir = $(libdir)/cmake +cmakedir = $(libdir)/cmake/ethercat -cmake_DATA = EtherCATConfig.cmake +cmake_DATA = ethercat-config.cmake -EXTRA_DIST = EtherCATConfig.cmake.in +EXTRA_DIST = ethercat-config.cmake.in CLEANFILES = $(cmake_DATA) @@ -110,5 +110,5 @@ endif # we need to replace the variables manually, because autotools does not expand them. -EtherCATConfig.cmake: $(srcdir)/EtherCATConfig.cmake.in Makefile +ethercat-config.cmake: $(srcdir)/ethercat-config.cmake.in Makefile $(SED) -e 's,%libdir%,$(libdir),' -e 's,%includedir%,$(includedir),' $< > $@ diff --git a/lib/EtherCATConfig.cmake.in b/lib/ethercat-config.cmake.in similarity index 90% rename from lib/EtherCATConfig.cmake.in rename to lib/ethercat-config.cmake.in index a803ac0c..e516f5a8 100644 --- a/lib/EtherCATConfig.cmake.in +++ b/lib/ethercat-config.cmake.in @@ -29,7 +29,7 @@ find_library(EtherCAT_LIBRARY - NAMES EtherCAT + NAMES ethercat PATHS %libdir% ) @@ -40,9 +40,9 @@ find_path(EtherCAT_INCLUDE_DIR 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 +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}" ) From 7e4aba9a6d8768a665ab96a2e45e3048c04ba196 Mon Sep 17 00:00:00 2001 From: Bjarne von Horn Date: Tue, 22 Feb 2022 23:28:42 +0100 Subject: [PATCH 2/2] build user example with cmake and test it --- .gitignore | 3 ++- .gitlab-ci.yml | 13 +++++++++++++ examples/user/CMakeLists.txt | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 examples/user/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 3b085f26..914e5e2f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,8 @@ configure ethercat.spec examples/dc_user/ec_dc_user_example examples/user/ec_user_example -lib/EtherCATConfig.cmake +examples/user/build/ +lib/*.cmake lib/libethercat.la lib/libethercat.pc libtool diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e271a62e..3386d4e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,19 @@ build: - make -j8 all modules - make DISTCHECK_CONFIGURE_FLAGS="--with-linux-dir=/usr/src/linux-obj/$(uname -i)/default" distcheck +test cmake: + stage: test + + script: + - ./bootstrap + - ./configure --prefix=/tmp/ethercat_test_dir --disable-kernel + - make -j8 install + - cd examples/user + - mkdir build && cd build + - cmake -DCMAKE_PREFIX_PATH=/tmp/ethercat_test_dir -DCMAKE_BUILD_TYPE=Release .. + - make + - ldd userexample + pages: stage: deploy rules: diff --git a/examples/user/CMakeLists.txt b/examples/user/CMakeLists.txt new file mode 100644 index 00000000..2b112add --- /dev/null +++ b/examples/user/CMakeLists.txt @@ -0,0 +1,10 @@ +project(EtherCatUserExample C) +cmake_minimum_required(VERSION 3.2) + +find_package(EtherCAT REQUIRED) + +add_executable(userexample + main.c +) + +target_link_libraries(userexample PUBLIC EtherLab::ethercat)