From 2db97684e5a1555ef417254549c7942dc32ff7ff Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Tue, 9 Nov 2021 12:18:58 +0100 Subject: [PATCH 1/7] Fix catkin_lint errors due to 'catkin_package DEPENDS' misconfiguration and multiple catkin_package calls. Use find_package(Threads) and THREADS_PREFER_PTHREAD_FLAG ON to configure both compiler and linker -pthread flags. --- CMakeLists.txt | 26 +++++++++++++------------- cmake/Findpthread.cmake | 10 ++++++++++ cmake/Findrt.cmake | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 cmake/Findpthread.cmake create mode 100644 cmake/Findrt.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 49270209..a91ac627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 2.8.3) project(serial) +set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ) # Find catkin find_package(catkin REQUIRED) @@ -11,20 +12,19 @@ endif() if(UNIX AND NOT APPLE) # If Linux, add rt and pthread - set(rt_LIBRARIES rt) - set(pthread_LIBRARIES pthread) - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - DEPENDS rt pthread - ) + find_package(pthread) + find_package(rt) + set(CATKIN_PACKAGE_DEPENDS "rt pthread") + #message("rt_LIBRARIES=${rt_LIBRARIES}") + #message("pthread_LIBRARIES=${pthread_LIBRARIES}") else() - # Otherwise normal call - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - ) + set(CATKIN_PACKAGE_DEPENDS "") endif() +catkin_package( + LIBRARIES ${PROJECT_NAME} + INCLUDE_DIRS include + DEPENDS ${CATKIN_PACKAGE_DEPENDS} +) ## Sources set(serial_SRCS @@ -51,7 +51,7 @@ add_library(${PROJECT_NAME} ${serial_SRCS}) if(APPLE) target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) elseif(UNIX) - target_link_libraries(${PROJECT_NAME} rt pthread) + target_link_libraries(${PROJECT_NAME} ${rt_LIBRARIES} ${pthread_LIBRARIES}) else() target_link_libraries(${PROJECT_NAME} setupapi) endif() diff --git a/cmake/Findpthread.cmake b/cmake/Findpthread.cmake new file mode 100644 index 00000000..9ada7e61 --- /dev/null +++ b/cmake/Findpthread.cmake @@ -0,0 +1,10 @@ +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + +if(Threads_FOUND) + #message( "lib pthread FOUND!" ) + set(pthread_LIBRARIES Threads::Threads) + set(pthread_INCLUDE_DIRS ${Threads_INCLUDE_DIR}) +else(Threads_FOUND) + #message( "lib pthread NOT FOUND!" ) +endif() diff --git a/cmake/Findrt.cmake b/cmake/Findrt.cmake new file mode 100644 index 00000000..a99547c6 --- /dev/null +++ b/cmake/Findrt.cmake @@ -0,0 +1,16 @@ +include(FindPackageHandleStandardArgs) + +find_library(rt_LIBRARY rt) + +find_package_handle_standard_args(rt + DEFAULT_MSG + rt_LIBRARY +) +mark_as_advanced(rt_LIBRARY) + +if(rt_FOUND) + #message("lib rt FOUND!") + set(rt_LIBRARIES ${rt_LIBRARY}) +else(rt_FOUND) + #message("lib rt NOT FOUND!") +endif() From f4ab9780622dd14b66f9acbb764b782aec7b8317 Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Tue, 9 Nov 2021 13:29:18 +0100 Subject: [PATCH 2/7] try to fix catkin_lint error: 'unknown boost' --- deps.repos | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 deps.repos diff --git a/deps.repos b/deps.repos new file mode 100644 index 00000000..a6ea786b --- /dev/null +++ b/deps.repos @@ -0,0 +1,3 @@ +apt: + - libboost-dev + From ca4e951247972edc121139d67fd6120405894d0a Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Tue, 9 Nov 2021 16:27:56 +0100 Subject: [PATCH 3/7] Add missing deps in CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a91ac627..fdfb8ef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" # Find catkin find_package(catkin REQUIRED) +find_package(Boost REQUIRED) if(APPLE) find_library(IOKIT_LIBRARY IOKit) From 08072ffec08660d09a97f0a0b6589425f16b7a3c Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Tue, 9 Nov 2021 17:51:24 +0100 Subject: [PATCH 4/7] boost to Boost in package.xml --- package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.xml b/package.xml index 27781e14..5c0de921 100644 --- a/package.xml +++ b/package.xml @@ -21,6 +21,6 @@ catkin - boost + Boost From 39bcf53062522f6f4a5f3962b48974cab5786078 Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Tue, 9 Nov 2021 22:49:08 +0100 Subject: [PATCH 5/7] try fix catkin_int for gitlab ci --- CMakeLists.txt | 4 +++- package.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdfb8ef6..39c6ceec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,9 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" # Find catkin find_package(catkin REQUIRED) -find_package(Boost REQUIRED) +if(CATKIN_ENABLE_TESTING) + find_package(Boost REQUIRED) +endif() if(APPLE) find_library(IOKIT_LIBRARY IOKit) diff --git a/package.xml b/package.xml index 5c0de921..27781e14 100644 --- a/package.xml +++ b/package.xml @@ -21,6 +21,6 @@ catkin - Boost + boost From 6c721f77caa3b744057e0de9a53d3941e40a968f Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Wed, 17 Nov 2021 13:06:21 +0100 Subject: [PATCH 6/7] try to fix boost depend for forge --- package.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.xml b/package.xml index 27781e14..aa62250b 100644 --- a/package.xml +++ b/package.xml @@ -20,7 +20,6 @@ John Harrison catkin - - boost + boost From 0f073498470dbf6a347032085c803f04fec06812 Mon Sep 17 00:00:00 2001 From: Augustin Manecy Date: Wed, 17 Nov 2021 18:21:47 +0100 Subject: [PATCH 7/7] try fix gitlabci --- package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.xml b/package.xml index aa62250b..2f9cea88 100644 --- a/package.xml +++ b/package.xml @@ -20,6 +20,6 @@ John Harrison catkin - boost + Boost