1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00
serial/CMakeLists.txt

88 lines
2.3 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 2.8.3)
project(serial)
set (SERIAL_VERSION_MAJOR 1)
set (SERIAL_VERSION_MINOR 2)
set (SERIAL_VERSION_PATCH 1)
# Find catkin
find_package(catkin REQUIRED)
if(APPLE)
2018-11-12 12:01:58 -06:00
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
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
)
2012-12-03 14:51:10 -08:00
else()
# Otherwise normal call
catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
)
2012-12-03 14:51:10 -08:00
endif()
## Sources
set(serial_SRCS
src/serial.cc
2012-12-03 15:31:41 -08:00
include/serial/serial.h
include/serial/v8stdint.h
)
if(APPLE)
2018-11-12 12:01:58 -06:00
# If OSX
list(APPEND serial_SRCS src/impl/unix.cc)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
elseif(UNIX)
# If unix
2012-12-03 15:31:41 -08:00
list(APPEND serial_SRCS src/impl/unix.cc)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
2014-08-16 22:08:56 +02:00
else()
# 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)
endif()
## Add serial library
add_library(${PROJECT_NAME} SHARED ${serial_SRCS})
if(APPLE)
2018-11-12 12:01:58 -06:00
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX)
2018-11-12 12:01:58 -06:00
target_link_libraries(${PROJECT_NAME} rt pthread)
2014-08-16 22:08:56 +02:00
else()
2018-11-12 12:01:58 -06:00
target_link_libraries(${PROJECT_NAME} setupapi)
endif()
## Uncomment for example
# add_executable(serial_example examples/serial_example.cc)
# add_dependencies(serial_example ${PROJECT_NAME})
# target_link_libraries(serial_example ${PROJECT_NAME})
set (SERIAL_VERSION_STRING ${SERIAL_VERSION_MAJOR}.${SERIAL_VERSION_MINOR}.${SERIAL_VERSION_PATCH})
set_target_properties (${PROJECT_NAME} PROPERTIES VERSION ${SERIAL_VERSION_STRING} SOVERSION ${SERIAL_VERSION_MAJOR})
## Include headers
include_directories(include)
## Install executable
2013-01-09 10:53:58 -08:00
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
2013-01-09 10:53:58 -08:00
## Install headers
install(FILES include/serial/serial.h include/serial/v8stdint.h
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial)
## Tests
if(CATKIN_ENABLE_TESTING)
add_subdirectory(tests)
endif()