forked from RoverRobotics-forks/serial-ros2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
70 lines (56 loc) · 1.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cmake_minimum_required(VERSION 3.5)
project(serial)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(ament_cmake REQUIRED)
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
## Sources
## Add serial library
add_library(${PROJECT_NAME}
src/serial.cc
include/serial/serial.h
include/serial/v8stdint.h
)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
if(APPLE) # macOS
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
target_sources(${PROJECT_NAME} PRIVATE
src/impl/unix.cc
src/impl/list_ports/list_ports_osx.cc
)
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX) # .*nix
target_sources(${PROJECT_NAME} PRIVATE
src/impl/unix.cc
src/impl/list_ports/list_ports_linux.cc
)
target_link_libraries(${PROJECT_NAME} rt pthread)
elseif(WIN32) # Windows
target_sources(${PROJECT_NAME} PRIVATE
src/impl/win.cc
src/impl/list_ports/list_ports_win.cc
)
target_link_libraries(${PROJECT_NAME} setupapi)
ament_export_libraries(setupapi)
endif()
## Include headers
target_include_directories(${PROJECT_NAME} PRIVATE include)
## Uncomment for example
# add_executable(serial_example examples/serial_example.cc)
# add_dependencies(serial_example ${PROJECT_NAME})
# target_link_libraries(serial_example ${PROJECT_NAME})
## Install executable
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
## Install headers
install(FILES include/serial/serial.h include/serial/v8stdint.h
DESTINATION include/serial
)
## Tests
#if(BUILD_TESTING)
# add_subdirectory(tests)
#endif()
ament_package()