]> Git Repo - serial.git/blob - CMakeLists.txt
Make Release|Win32 configuration compile
[serial.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.3)
2 project(serial)
3
4 # Find catkin
5 find_package(catkin REQUIRED)
6
7 if(APPLE)
8         find_library(IOKIT_LIBRARY IOKit)
9         find_library(FOUNDATION_LIBRARY Foundation)
10 endif()
11
12 if(UNIX AND NOT APPLE)
13     # If Linux, add rt and pthread
14     catkin_package(
15         LIBRARIES ${PROJECT_NAME}
16         INCLUDE_DIRS include
17         DEPENDS rt pthread
18     )
19 else()
20     # Otherwise normal call
21     catkin_package(
22         LIBRARIES ${PROJECT_NAME}
23         INCLUDE_DIRS include
24     )
25 endif()
26
27 ## Sources
28 set(serial_SRCS
29     src/serial.cc
30     include/serial/serial.h
31     include/serial/v8stdint.h
32 )
33 if(APPLE)
34         # If OSX
35         list(APPEND serial_SRCS src/impl/unix.cc)
36         list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
37 elseif(UNIX)
38     # If unix
39     list(APPEND serial_SRCS src/impl/unix.cc)
40     list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
41 elseif()
42     # If windows
43     list(APPEND serial_SRCS src/impl/win.cc)
44 endif()
45
46 ## Add serial library
47 add_library(${PROJECT_NAME} ${serial_SRCS})
48 if(APPLE)
49         target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
50 elseif(UNIX)
51         target_link_libraries(${PROJECT_NAME} rt pthread)
52 endif()
53
54 ## Uncomment for example
55 add_executable(serial_example examples/serial_example.cc)
56 add_dependencies(serial_example ${PROJECT_NAME})
57 target_link_libraries(serial_example ${PROJECT_NAME})
58
59 ## Include headers
60 include_directories(include)
61
62 ## Install executable
63 install(TARGETS ${PROJECT_NAME}
64     ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
65     LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
66 )
67
68 ## Install headers
69 install(FILES include/serial/serial.h include/serial/v8stdint.h
70   DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial)
71
72 ## Tests
73 if(CATKIN_ENABLE_TESTING)
74     add_subdirectory(tests)
75 endif()
This page took 0.027427 seconds and 4 git commands to generate.