From 9cf38d0e99f44f9c51a721f5cdcb0720a0332789 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sun, 24 Jan 2016 11:23:02 +0100 Subject: [PATCH 1/2] Made catkin optional with automatic selection if it is available --- CMakeLists.txt | 60 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a72acb8..6414449 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,26 +2,28 @@ cmake_minimum_required(VERSION 2.8.3) project(serial) # Find catkin -find_package(catkin REQUIRED) +find_package(catkin QUIET) if(APPLE) find_library(IOKIT_LIBRARY IOKit) find_library(FOUNDATION_LIBRARY Foundation) endif() -if(UNIX AND NOT APPLE) - # If Linux, add rt and pthread - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - DEPENDS rt pthread - ) -else() - # Otherwise normal call - catkin_package( - LIBRARIES ${PROJECT_NAME} - INCLUDE_DIRS include - ) +if (catkin_FOUND) + if(UNIX AND NOT APPLE) + # If Linux, add rt and pthread + catkin_package( + LIBRARIES ${PROJECT_NAME} + INCLUDE_DIRS include + DEPENDS rt pthread + ) + else() + # Otherwise normal call + catkin_package( + LIBRARIES ${PROJECT_NAME} + INCLUDE_DIRS include + ) + endif() endif() ## Sources @@ -63,16 +65,30 @@ target_link_libraries(serial_example ${PROJECT_NAME}) include_directories(include) ## Install executable -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} -) +if (catkin_FOUND) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ) +else() + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + ) +endif() ## Install headers -install(FILES include/serial/serial.h include/serial/v8stdint.h - DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) +if (catkin_FOUND) + install(FILES include/serial/serial.h include/serial/v8stdint.h + DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) +else() + install(FILES include/serial/serial.h include/serial/v8stdint.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/serial) +endif() ## Tests -if(CATKIN_ENABLE_TESTING) - add_subdirectory(tests) +if (catkin_FOUND) + if(CATKIN_ENABLE_TESTING) + add_subdirectory(tests) + endif() endif() From 06971e07f80ff79e0b2516518ecdaa8bbedd2cc0 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sun, 24 Jan 2016 12:21:30 +0100 Subject: [PATCH 2/2] Updated include path, was the wrong path --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6414449..1910649 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ if (catkin_FOUND) DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) else() install(FILES include/serial/serial.h include/serial/v8stdint.h - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial) + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/serial) endif() ## Tests