2016-07-18 11:12:04 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8.3)
|
2012-10-23 23:47:11 -07:00
|
|
|
project(serial)
|
|
|
|
|
|
2014-04-25 02:50:40 +01:00
|
|
|
if(APPLE)
|
|
|
|
|
find_library(IOKIT_LIBRARY IOKit)
|
|
|
|
|
find_library(FOUNDATION_LIBRARY Foundation)
|
|
|
|
|
endif()
|
|
|
|
|
|
2012-10-23 23:47:11 -07:00
|
|
|
## Sources
|
|
|
|
|
set(serial_SRCS
|
|
|
|
|
src/serial.cc
|
2012-12-03 15:31:41 -08:00
|
|
|
include/serial/serial.h
|
|
|
|
|
include/serial/v8stdint.h
|
2012-10-23 23:47:11 -07:00
|
|
|
)
|
2014-04-25 02:50:40 +01:00
|
|
|
if(APPLE)
|
|
|
|
|
# If OSX
|
|
|
|
|
list(APPEND serial_SRCS src/impl/unix.cc)
|
|
|
|
|
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
|
|
|
|
|
elseif(UNIX)
|
2012-10-23 23:47:11 -07:00
|
|
|
# If unix
|
2012-12-03 15:31:41 -08:00
|
|
|
list(APPEND serial_SRCS src/impl/unix.cc)
|
2014-02-22 20:02:32 +00:00
|
|
|
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
|
2014-08-16 22:08:56 +02:00
|
|
|
else()
|
2012-10-23 23:47:11 -07:00
|
|
|
# If windows
|
2012-12-03 15:31:41 -08:00
|
|
|
list(APPEND serial_SRCS src/impl/win.cc)
|
2014-08-16 22:08:56 +02:00
|
|
|
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc)
|
2012-10-23 23:47:11 -07:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
## Add serial library
|
2016-07-12 09:25:24 +02:00
|
|
|
add_library(${PROJECT_NAME} STATIC ${serial_SRCS})
|
2014-04-25 02:50:40 +01:00
|
|
|
if(APPLE)
|
2014-07-02 15:23:23 -07:00
|
|
|
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
|
2014-04-25 02:50:40 +01:00
|
|
|
elseif(UNIX)
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} rt pthread)
|
2014-08-16 22:08:56 +02:00
|
|
|
else()
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} setupapi)
|
2012-10-24 01:32:23 -07:00
|
|
|
endif()
|
2012-10-23 23:47:11 -07:00
|
|
|
|
2016-07-12 18:41:18 +02:00
|
|
|
## Add example project
|
2012-10-23 23:47:11 -07:00
|
|
|
add_executable(serial_example examples/serial_example.cc)
|
|
|
|
|
add_dependencies(serial_example ${PROJECT_NAME})
|
|
|
|
|
target_link_libraries(serial_example ${PROJECT_NAME})
|
|
|
|
|
|
|
|
|
|
## Include headers
|
|
|
|
|
include_directories(include)
|
|
|
|
|
|
2016-07-12 18:41:18 +02:00
|
|
|
## Install
|
|
|
|
|
set(INSTALL_LIB_DIR lib)
|
|
|
|
|
set(INSTALL_INCLUDE_DIR include)
|
|
|
|
|
set(INSTALL_CMAKE_DIR share/serial/cmake)
|
|
|
|
|
|
2012-10-23 23:47:11 -07:00
|
|
|
## Install executable
|
2013-01-09 10:53:58 -08:00
|
|
|
install(TARGETS ${PROJECT_NAME}
|
2016-07-12 18:41:18 +02:00
|
|
|
DESTINATION ${INSTALL_LIB_DIR}
|
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
2012-10-23 23:47:11 -07:00
|
|
|
)
|
|
|
|
|
|
2013-01-09 10:53:58 -08:00
|
|
|
## Install headers
|
|
|
|
|
install(FILES include/serial/serial.h include/serial/v8stdint.h
|
2016-07-12 18:41:18 +02:00
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/serial)
|
|
|
|
|
|
|
|
|
|
## Install CMake files
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR})
|
|
|
|
|
|
2016-07-18 11:46:51 +02:00
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
|
2016-07-12 18:41:18 +02:00
|
|
|
DESTINATION ${INSTALL_CMAKE_DIR})
|
2013-01-09 10:53:58 -08:00
|
|
|
|
2012-10-23 23:47:11 -07:00
|
|
|
## Tests
|
2016-07-12 18:41:18 +02:00
|
|
|
# FIXME
|
|
|
|
|
#if(CATKIN_ENABLE_TESTING)
|
|
|
|
|
# add_subdirectory(tests)
|
|
|
|
|
#endif()
|