|
| 1 | +#.rst: |
| 2 | +# FindMStack |
| 3 | +# ----------- |
| 4 | +# |
| 5 | +# Finds the M-Stack USB stack for Microchip PIC MCUs. |
| 6 | +# |
| 7 | +# Copyright 2016 Sam Hanes |
| 8 | +# |
| 9 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | +# of this software and associated documentation files (the "Software"), to deal |
| 11 | +# in the Software without restriction, including without limitation the rights |
| 12 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | +# copies of the Software, and to permit persons to whom the Software is |
| 14 | +# furnished to do so, subject to the following conditions: |
| 15 | +# |
| 16 | +# The above copyright notice and this permission notice shall be included in |
| 17 | +# all copies or substantial portions of the Software. |
| 18 | +# |
| 19 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | +# SOFTWARE. |
| 26 | + |
| 27 | + |
| 28 | +set(MStack_ROOT external/m-stack |
| 29 | + CACHE PATH "the root of the M-Stack source checkout" |
| 30 | +) |
| 31 | +get_filename_component(MStack_ROOT "${MStack_ROOT}" ABSOLUTE) |
| 32 | + |
| 33 | +set(MStack_USB_ROOT ${MStack_ROOT}/usb) |
| 34 | + |
| 35 | +include(FindPackageHandleStandardArgs) |
| 36 | +find_package_handle_standard_args(MStack |
| 37 | + REQUIRED_VARS |
| 38 | + MStack_ROOT |
| 39 | +) |
| 40 | + |
| 41 | +if(NOT MStack_FOUND) |
| 42 | + return() |
| 43 | +endif() |
| 44 | + |
| 45 | +add_library(MStack INTERFACE) |
| 46 | +target_sources(MStack INTERFACE |
| 47 | + ${MStack_USB_ROOT}/src/usb.c |
| 48 | +) |
| 49 | +target_include_directories(MStack INTERFACE |
| 50 | + ${MStack_ROOT}/usb/include |
| 51 | +) |
| 52 | + |
| 53 | +add_library(MStack_HID INTERFACE) |
| 54 | +target_sources(MStack_HID INTERFACE |
| 55 | + ${MStack_USB_ROOT}/src/usb_hid.c |
| 56 | +) |
| 57 | +target_link_libraries(MStack_HID |
| 58 | + INTERFACE MStack |
| 59 | +) |
0 commit comments