|
1 | 1 | cmake_minimum_required(VERSION 3.3.0) |
2 | 2 |
|
3 | | -set(UART_SRC src/uart.cpp) |
| 3 | +add_library(uart INTERFACE) |
| 4 | + |
| 5 | +target_sources(uart INTERFACE |
| 6 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/uart.cpp> |
| 7 | + $<INSTALL_INTERFACE:${LIB_INSTALL_DIR}/sdk/uart/uart.cpp>) |
4 | 8 |
|
5 | 9 | if(WIN32) |
6 | | - list(APPEND UART_SRC src/win32/uartimpl.cpp) |
| 10 | + target_sources(uart INTERFACE |
| 11 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/win32/uartimpl.cpp> |
| 12 | + $<INSTALL_INTERFACE:${LIB_INSTALL_DIR}/sdk/uart/win32/uartimpl.cpp>) |
7 | 13 | else() |
8 | | - list(APPEND UART_SRC src/posix/uartimpl.cpp) |
| 14 | + target_sources(uart INTERFACE |
| 15 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/posix/uartimpl.cpp> |
| 16 | + $<INSTALL_INTERFACE:${LIB_INSTALL_DIR}/sdk/uart/posix/uartimpl.cpp>) |
9 | 17 | endif() |
10 | 18 |
|
11 | | -add_library(uart ${UART_SRC}) |
12 | | - |
13 | | -target_include_directories(uart PUBLIC |
| 19 | +target_include_directories(uart INTERFACE |
14 | 20 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
15 | 21 | $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}/sdk/uart>) |
16 | 22 |
|
17 | | -target_include_directories(uart PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) |
18 | | - |
19 | | -set_target_properties(uart PROPERTIES POSITION_INDEPENDENT_CODE TRUE) |
20 | | - |
21 | 23 | ########################### |
22 | 24 | # INSTALL |
23 | 25 | ########################### |
24 | 26 |
|
25 | | -install(TARGETS uart |
26 | | - EXPORT sdm |
27 | | - LIBRARY DESTINATION "${LIB_INSTALL_DIR}/sdk" |
28 | | - ARCHIVE DESTINATION "${LIB_INSTALL_DIR}/sdk") |
| 27 | +install(TARGETS uart EXPORT sdm) |
29 | 28 |
|
30 | 29 | install(DIRECTORY include/ |
31 | 30 | DESTINATION "${INCLUDE_INSTALL_DIR}/sdk/uart") |
| 31 | + |
| 32 | +install(DIRECTORY src/ |
| 33 | + DESTINATION "${LIB_INSTALL_DIR}/sdk/uart") |
0 commit comments