From 4a52ad6c4f61582884082fac8a1bc0699dd5d18d Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 14 Apr 2016 13:52:09 +0100 Subject: [PATCH] uart_ow: Make onewire functionality optional but on by default Signed-off-by: Brendan Le Foll --- CMakeLists.txt | 1 + examples/CMakeLists.txt | 7 +++++-- examples/c++/CMakeLists.txt | 7 +++++-- src/CMakeLists.txt | 6 +++++- src/javascript/binding.gyp.cmake | 1 + src/uart_ow/CMakeLists.txt | 7 +++++++ 6 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/uart_ow/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index bfd4000..d18d269 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ option (BUILDSWIGNODE "Build swig node modules." ON) option (BUILDSWIGJAVA "Build Java API." OFF) option (USBPLAT "Detection USB platform." OFF) option (FIRMATA "Add Firmata support to mraa." OFF) +option (ONEWIRE "Add Onewire support to mraa." ON) option (IMRAA "Add Imraa support to mraa." OFF) option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF) option (IPK "Generate IPK using CPack" OFF) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 297d965..0cb7756 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -9,7 +9,6 @@ add_executable (spi_mcp4261 spi_mcp4261.c) add_executable (mmap-io2 mmap-io2.c) add_executable (blink_onboard blink_onboard.c) add_executable (uart uart.c) -add_executable (uart_ow uart_ow.c) add_executable (mraa-gpio mraa-gpio.c) add_executable (mraa-i2c mraa-i2c.c) add_executable (spi_max7219 spi_max7219.c) @@ -31,12 +30,16 @@ target_link_libraries (spi_mcp4261 mraa) target_link_libraries (mmap-io2 mraa) target_link_libraries (blink_onboard mraa) target_link_libraries (uart mraa) -target_link_libraries (uart_ow mraa) target_link_libraries (mraa-gpio mraa) target_link_libraries (mraa-i2c mraa) target_link_libraries (spi_max7219 mraa) target_link_libraries (iio_driver mraa) +if (ONEWIRE) + add_executable (uart_ow uart_ow.c) + target_link_libraries (uart_ow mraa) +endif () + if (FIRMATA) add_executable (firmata_curie_imu firmata_curie_imu.c) add_executable (i2c_firmata i2c_firmata.c) diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index e9faca8..51a3f3a 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -8,7 +8,6 @@ add_executable (Spi-pot Spi-pot.cpp) add_executable (Uart Uart-example.cpp) add_executable (Isr-pin6 Isr-pin6.cpp) add_executable (Iio-dummy Iio-dummy.cpp) -add_executable (UartOW UartOW.cpp) include_directories(${PROJECT_SOURCE_DIR}/api) @@ -20,4 +19,8 @@ target_link_libraries (Spi-pot mraa stdc++) target_link_libraries (Uart mraa stdc++) target_link_libraries (Isr-pin6 mraa stdc++) target_link_libraries (Iio-dummy mraa stdc++) -target_link_libraries (UartOW mraa stdc++) + +if (ONEWIRE) + add_executable (UartOW UartOW.cpp) + target_link_libraries (UartOW mraa stdc++) +endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6b45eb..bac836e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,11 @@ if (FIRMATA) add_subdirectory (firmata) endif () +if (ONEWIRE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DONEWIRE=1") + add_subdirectory (uart_ow) +endif () + include_directories( ${mraa_LIB_INCLUDE_DIRS} ) @@ -23,7 +28,6 @@ set (mraa_LIB_SRCS_NOAUTO ${PROJECT_SOURCE_DIR}/src/uart/uart.c ${PROJECT_SOURCE_DIR}/src/iio/iio.c ${mraa_LIB_SRCS_NOAUTO} - ${PROJECT_SOURCE_DIR}/src/uart_ow/uart_ow.c ) set (mraa_LIB_X86_SRCS_NOAUTO diff --git a/src/javascript/binding.gyp.cmake b/src/javascript/binding.gyp.cmake index 7487bf7..9e3c40a 100644 --- a/src/javascript/binding.gyp.cmake +++ b/src/javascript/binding.gyp.cmake @@ -29,6 +29,7 @@ 'defines' : [ 'SWIG', 'SWIGJAVASCRIPT', 'FIRMATA=ON', + 'ONEWIRE=ON', 'BUILDING_NODE_EXTENSION=1', 'SWIG_V8_VERSION=0x0<(v8_version)', 'V8_VERSION=0x0<(v8_version)' diff --git a/src/uart_ow/CMakeLists.txt b/src/uart_ow/CMakeLists.txt new file mode 100644 index 0000000..8ea5bdb --- /dev/null +++ b/src/uart_ow/CMakeLists.txt @@ -0,0 +1,7 @@ +if (ONEWIRE) + message (STATUS "INFO - Adding onewire backend support") + set (mraa_LIB_SRCS_NOAUTO ${mraa_LIB_SRCS_NOAUTO} + ${PROJECT_SOURCE_DIR}/src/uart_ow/uart_ow.c + PARENT_SCOPE + ) +endif ()