From 866d7b184a2b714877a92979967d7d0aa81de605 Mon Sep 17 00:00:00 2001 From: marcfir Date: Tue, 20 Aug 2024 18:36:07 +0000 Subject: [PATCH 1/2] doc: Fix typo in cmake --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1bd053..64b7191 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ mkdir build cd build # Please change the path to the install dir. If you chose a global install you can omit the CMAKE_PREFIX_PATH option # You can specify which EtherCAT devices should be included into the build with -DECAT_DEVICE="sock_raw+sock_raw_mmaped+..." -cmake .. -DCMAKE_PREFIX_PATH= -DECAT_DEVICE="sock_raw+sock_raw_mmaped" +cmake -DCMAKE_PREFIX_PATH= -DECAT_DEVICE="sock_raw+sock_raw_mmaped" .. cmake --build . ``` From a13fdab3ea8db1bdff3efed462000c675c9eb0dc Mon Sep 17 00:00:00 2001 From: marcfir Date: Wed, 7 Aug 2024 07:17:06 +0000 Subject: [PATCH 2/2] feat(cmake): Use config.h to set the preprocessor device variables --- CMakeLists.txt | 15 +++++++-------- cmake/cmake_config.h.in | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b6cda8..678b1b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,9 +66,6 @@ find_package (Threads REQUIRED) include_directories(${libosal_INCLUDE_DIRS} include) link_directories(${libosal_LIB_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/libethercat/config.h) - - set(SRC_ETHERCAT src/async_loop.c src/coe.c @@ -96,29 +93,31 @@ list(FIND ECAT_DEVICE "bpf" HAS_SOCK_BPF) if (${HAS_SOCK_RAW} GREATER -1) message("Include device sock_raw") list(APPEND SRC_HW_LAYER src/hw_sock_raw.c) - add_compile_definitions(LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_LEGACY) + set(LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_LEGACY 1) endif() if (${HAS_SOCK_RAW_MMAPED} GREATER -1) message("Include device sock_raw_mmaped") list(APPEND SRC_HW_LAYER src/hw_sock_raw_mmaped.c) - add_compile_definitions(LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_MMAPED) + set(LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_MMAPED 1) endif() if (${HAS_SOCK_FILE} GREATER -1) message("Include device file") list(APPEND SRC_HW_LAYER src/hw_file.c) - add_compile_definitions(LIBETHERCAT_BUILD_DEVICE_FILE) + set(LIBETHERCAT_BUILD_DEVICE_FILE 1) endif() if (${HAS_SOCK_PIKEOS} GREATER -1) message("Include device pikeos") list(APPEND SRC_HW_LAYER src/hw_pikeos.c) - add_compile_definitions(LIBETHERCAT_BUILD_DEVICE_PIKEOS) + set(LIBETHERCAT_BUILD_DEVICE_PIKEOS 1) endif() if (${HAS_SOCK_BPF} GREATER -1) message("Include device bpf") list(APPEND SRC_HW_LAYER src/hw_bpf.c) - add_compile_definitions(LIBETHERCAT_BUILD_DEVICE_BPD) + set(LIBETHERCAT_BUILD_DEVICE_BPF 1) endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/libethercat/config.h) + # LIBS add_library(ethercat ${SRC_ETHERCAT} ${SRC_HW_LAYER}) target_link_libraries (ethercat ${CMAKE_THREAD_LIBS_INIT} ${libosal_LIBS}) diff --git a/cmake/cmake_config.h.in b/cmake/cmake_config.h.in index 6421a51..91d7373 100644 --- a/cmake/cmake_config.h.in +++ b/cmake/cmake_config.h.in @@ -124,6 +124,21 @@ /* Define to the version of this package. */ #cmakedefine LIBETHERCAT_VERSION "@LIBETHERCAT_VERSION@" +/* Define to build DEVICE_SOCK_RAW_LEGACY. */ +#cmakedefine LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_LEGACY ${LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_LEGACY} + +/* Define to build DEVICE_SOCK_RAW_MMAPED. */ +#cmakedefine LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_MMAPED ${LIBETHERCAT_BUILD_DEVICE_SOCK_RAW_MMAPED} + +/* Define to build DEVICE_FILE. */ +#cmakedefine LIBETHERCAT_BUILD_DEVICE_FILE ${LIBETHERCAT_BUILD_DEVICE_FILE} + +/* Define to build BUILD_DEVICE_PIKEOS. */ +#cmakedefine LIBETHERCAT_BUILD_DEVICE_PIKEOS ${LIBETHERCAT_BUILD_DEVICE_PIKEOS} + +/* Define to build BUILD_DEVICE_BPD. */ +#cmakedefine LIBETHERCAT_BUILD_DEVICE_BPF ${LIBETHERCAT_BUILD_DEVICE_BPF} + /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE