~aleteoryx/muditaos

ref: a405cad694b867fcd2498984830bd97d4b9bde2f muditaos/cmake/modules/SerialPort.cmake -rw-r--r-- 1.4 KiB
a405cad6Aleteoryx trim readme 7 days ago
                                                                                
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
# This modul checks if "SERIAL_PORT" for linux target variable is set
# if yes define_serial_port macro can be used to set proper definitions
#
#####
#   define_serial(TARGET_NAME)
#
#  this checks if SERIAL_PORT variable is defined and if so, add proper defines
#  for the specified target
#
#####
#   message_serial_status()
#
#  This macro can be used to message if and which port is used

include(Colours)

macro(define_serial)
    if(NOT ${ARGC} EQUAL 1 )
        message(WARNING "No target specified!")
    else()
        if(${PROJECT_TARGET} STREQUAL "TARGET_Linux")
            if (SERIAL_PORT)
                set(SERIAL_PORT_DEF "SERIAL_PORT=\"${SERIAL_PORT}\"")
                target_compile_definitions(
                    ${ARGV0}
                    PUBLIC
                    ${SERIAL_PORT_DEF}
                )
           endif()
       endif()
    endif()
endmacro()

macro(message_serial_status)
    if(${PROJECT_TARGET} STREQUAL "TARGET_Linux")
        if (SERIAL_PORT_DEF)
            message("Using serial port: ${SERIAL_PORT_DEF}")
        else()
            message ("${Orange}Serial Port not defined, modem support disabled! ${ColourReset}")
            message ("${Orange}add -DSERIAL_PORT=<path to serial> where modem is connected ${ColourReset}")
            message ("${Orange}ex.: \n ./configure.sh linux Debug -DSERIAL_PORT=/dev/ttyUSB0 ${ColourReset}")
        endif()
    endif()
endmacro()