From a310c4b020cc8d32749594216588aad571b45c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 11:47:43 +0200 Subject: [PATCH 1/7] .gitignore update .gitignore update for the sake of CLion environment --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b4bbe2cc..50c17937 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ install /doc/latex /doc/html tags +cmake-build* +.idea/* \ No newline at end of file From fd30df187cb4cdf2e0c55396aaf26751fb6f5d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:04:25 +0200 Subject: [PATCH 2/7] Usage of target_link_libraries instead of link_libraries for system libs Now variable OS_LIBS contains the system libraries too and the wpcap/packet libs with correct build/install pathes (SoemConfig will inherit it) --- CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index baf26bd5..698641aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,13 +24,26 @@ if(WIN32) set(OS "win32") include_directories(oshw/win32/wpcap/Include) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib/x64) + SET(OS_LIBS Ws2_32.lib Winmm.lib + \$ + \$ + \$ + \$) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib) + SET(OS_LIBS Ws2_32.lib Winmm.lib + \$ + \$ + \$ + \$) endif() + + install(DIRECTORY "${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib/" + DESTINATION "lib/wpcap" + FILES_MATCHING + PATTERN "*.lib") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") - set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib) elseif(UNIX AND NOT APPLE) set(OS "linux") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") From 2d069eb3d2e099fb258a2effe62219aa83214262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:34:13 +0200 Subject: [PATCH 3/7] Unnecessary rows in target_include_directories commands Only cleaning --- CMakeLists.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 698641aa..0c37db7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,18 +91,9 @@ target_link_libraries(soem ${OS_LIBS}) target_include_directories(soem PUBLIC $ - $) - -target_include_directories(soem PUBLIC $ - $) - -target_include_directories(soem PUBLIC $ - $) - -target_include_directories(soem - PUBLIC $ + $ $ ) From ba3bcf542c13b0ad6882ef420cc99d915c613d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:45:59 +0200 Subject: [PATCH 4/7] CMake path in the package is unreasonably long --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c37db7d..af14b388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}") install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR}) -install(EXPORT soemConfig DESTINATION share/soem/cmake) +install(EXPORT soemConfig DESTINATION cmake) install(FILES ${SOEM_HEADERS} From 0b8164811fcfdc4769a9c3f0a2a1b6efad7ad987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:47:32 +0200 Subject: [PATCH 5/7] Variables used only once are substituted --- CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af14b388..aba866f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,9 +10,6 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install) endif() -set(SOEM_INCLUDE_INSTALL_DIR include/soem) -set(SOEM_LIB_INSTALL_DIR lib) - if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(BUILD_TESTS TRUE) else() @@ -97,17 +94,15 @@ target_include_directories(soem PUBLIC $ ) -message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}") - -install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR}) +install(TARGETS soem EXPORT soemConfig DESTINATION lib) install(EXPORT soemConfig DESTINATION cmake) install(FILES ${SOEM_HEADERS} ${OSAL_HEADERS} ${OSHW_HEADERS} - DESTINATION ${SOEM_INCLUDE_INSTALL_DIR}) + DESTINATION include/soem) if(BUILD_TESTS) add_subdirectory(test/simple_ng) From da54801e0150cd11872a8fa4f97b0e12294e47e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:50:44 +0200 Subject: [PATCH 6/7] Usage of target_include_directories instead of include_directories All of the requested libraries are listed in variable OS_INCLUDE (both the build and install pathes). The headers in question are copied into the package. --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aba866f0..7a42b43e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ endif() if(WIN32) set(OS "win32") - include_directories(oshw/win32/wpcap/Include) if(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(OS_LIBS Ws2_32.lib Winmm.lib \$ @@ -33,6 +32,17 @@ if(WIN32) \$ \$) endif() + + set(OS_INCLUDE + \$ + \$ + \$ + \$) + + install(DIRECTORY "${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Include/" + DESTINATION "include/wpcap" + FILES_MATCHING + PATTERN "*.h") install(DIRECTORY "${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib/" DESTINATION "lib/wpcap" @@ -92,8 +102,7 @@ target_include_directories(soem PUBLIC $ $ $ - ) - + ${OS_INCLUDE}) install(TARGETS soem EXPORT soemConfig DESTINATION lib) install(EXPORT soemConfig DESTINATION cmake) From e0432be29e04695c4731c4d02113951c59355394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Kuti?= Date: Mon, 17 Oct 2022 12:52:55 +0200 Subject: [PATCH 7/7] More versions of the libs (release/debug/Relwithdebinfo/minsizerel) can be in the package via postfixes For windows, the VS toolset & platform is also described (the config will link the appropriately one) --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a42b43e..4ceacc53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,16 @@ add_library(soem STATIC ${OSAL_SOURCES} ${OSHW_SOURCES} ${OSHW_EXTRA_SOURCES}) + +if(WIN32) + SET(ADD_INFO -${CMAKE_VS_PLATFORM_TOOLSET}-${CMAKE_GENERATOR_PLATFORM}-${RUNTIME_INFO}) +endif() +set_target_properties(soem PROPERTIES + RELEASE_POSTFIX "${ADD_INFO}" + RELWITHDEBINFO_POSTFIX "${ADD_INFO}-relwithdebinfo" + MINSIZEREL_POSTFIX "${ADD_INFO}-minsizerel" + DEBUG_POSTFIX "${ADD_INFO}-debug") + target_link_libraries(soem ${OS_LIBS}) target_include_directories(soem PUBLIC