Advertisement
Guest User

Untitled

a guest
May 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 1.94 KB | None | 0 0
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(serial)
  3.  
  4. if(APPLE)
  5.     find_library(IOKIT_LIBRARY IOKit)
  6.     find_library(FOUNDATION_LIBRARY Foundation)
  7. endif()
  8.  
  9. ## Sources
  10. set(serial_SRCS
  11.     src/serial.cc
  12.     include/serial/serial.h
  13.     include/serial/v8stdint.h
  14. )
  15. if(APPLE)
  16.     # If OSX
  17.     list(APPEND serial_SRCS src/impl/unix.cc)
  18.     list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
  19. elseif(UNIX)
  20.     # If unix
  21.     list(APPEND serial_SRCS src/impl/unix.cc)
  22.     list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
  23. else()
  24.     # If windows
  25.     list(APPEND serial_SRCS src/impl/win.cc)
  26.     list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc)
  27. endif()
  28.  
  29. ## Add serial library
  30. add_library(${PROJECT_NAME} STATIC ${serial_SRCS})
  31. if(APPLE)
  32.     target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
  33. elseif(UNIX)
  34.     target_link_libraries(${PROJECT_NAME} rt pthread)
  35. else()
  36.     target_link_libraries(${PROJECT_NAME} setupapi)
  37. endif()
  38.  
  39. ## Add example project
  40. add_executable(serial_example examples/serial_example.cc)
  41. add_dependencies(serial_example ${PROJECT_NAME})
  42. target_link_libraries(serial_example ${PROJECT_NAME})
  43.  
  44. ## Include headers
  45. include_directories(include)
  46.  
  47. ## Install
  48. set(INSTALL_LIB_DIR lib)
  49. set(INSTALL_INCLUDE_DIR include)
  50. set(INSTALL_CMAKE_DIR share/serial/cmake)
  51.  
  52. ## Install executable
  53. install(TARGETS ${PROJECT_NAME}
  54.     DESTINATION ${INSTALL_LIB_DIR}
  55.     EXPORT ${PROJECT_NAME}-targets
  56. )
  57.  
  58. ## Install headers
  59. install(FILES include/serial/serial.h include/serial/v8stdint.h
  60.     DESTINATION ${INSTALL_INCLUDE_DIR}/serial)
  61.  
  62. ## Install CMake files
  63. install(EXPORT ${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR})
  64.  
  65. install(FILES ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
  66.         DESTINATION ${INSTALL_CMAKE_DIR})
  67.  
  68. ## Tests
  69. # FIXME
  70. #if(CATKIN_ENABLE_TESTING)
  71. #    add_subdirectory(tests)
  72. #endif()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement