mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
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.
This commit is contained in:
parent
cbcca7c837
commit
2db97684e5
@ -1,5 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.3)
|
cmake_minimum_required(VERSION 2.8.3)
|
||||||
project(serial)
|
project(serial)
|
||||||
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
|
||||||
|
|
||||||
# Find catkin
|
# Find catkin
|
||||||
find_package(catkin REQUIRED)
|
find_package(catkin REQUIRED)
|
||||||
@ -11,20 +12,19 @@ endif()
|
|||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
# If Linux, add rt and pthread
|
# If Linux, add rt and pthread
|
||||||
set(rt_LIBRARIES rt)
|
find_package(pthread)
|
||||||
set(pthread_LIBRARIES pthread)
|
find_package(rt)
|
||||||
catkin_package(
|
set(CATKIN_PACKAGE_DEPENDS "rt pthread")
|
||||||
LIBRARIES ${PROJECT_NAME}
|
#message("rt_LIBRARIES=${rt_LIBRARIES}")
|
||||||
INCLUDE_DIRS include
|
#message("pthread_LIBRARIES=${pthread_LIBRARIES}")
|
||||||
DEPENDS rt pthread
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
# Otherwise normal call
|
set(CATKIN_PACKAGE_DEPENDS "")
|
||||||
catkin_package(
|
|
||||||
LIBRARIES ${PROJECT_NAME}
|
|
||||||
INCLUDE_DIRS include
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
catkin_package(
|
||||||
|
LIBRARIES ${PROJECT_NAME}
|
||||||
|
INCLUDE_DIRS include
|
||||||
|
DEPENDS ${CATKIN_PACKAGE_DEPENDS}
|
||||||
|
)
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
set(serial_SRCS
|
set(serial_SRCS
|
||||||
@ -51,7 +51,7 @@ add_library(${PROJECT_NAME} ${serial_SRCS})
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
|
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
target_link_libraries(${PROJECT_NAME} rt pthread)
|
target_link_libraries(${PROJECT_NAME} ${rt_LIBRARIES} ${pthread_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PROJECT_NAME} setupapi)
|
target_link_libraries(${PROJECT_NAME} setupapi)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
10
cmake/Findpthread.cmake
Normal file
10
cmake/Findpthread.cmake
Normal file
@ -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()
|
||||||
16
cmake/Findrt.cmake
Normal file
16
cmake/Findrt.cmake
Normal file
@ -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()
|
||||||
Loading…
x
Reference in New Issue
Block a user