diff --git a/CMakeLists.txt b/CMakeLists.txt index 49270209..39c6ceec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,12 @@ 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) +if(CATKIN_ENABLE_TESTING) + find_package(Boost REQUIRED) +endif() if(APPLE) find_library(IOKIT_LIBRARY IOKit) @@ -11,20 +15,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 +54,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() 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 + diff --git a/package.xml b/package.xml index 27781e14..2f9cea88 100644 --- a/package.xml +++ b/package.xml @@ -20,7 +20,6 @@ John Harrison catkin - - boost + Boost