bladeRF/host/cmake/modules/FindPatcher.cmake
Rey Tucker 48ec0a40a6
Move vendor library code for ad936x RFIC to /thirdparty; use git submodule (#689)
This PR creates a git submodule for the analogdevicesinc/no-OS code, moving it from host/libraries/libbladeRF/src/driver/thirdparty/adi/ to thirdparty/analogdevicesinc/no-OS and adjusting the build process accordingly.

The build process will handle the git submodule init / git submodule update as required, or it may be done manually before the build. It will then copy the necessary files to the build tree, apply a series of patches for local modifications, and then build it as libad936x.

There are no changes to the build steps, although the build will fail if git submodule init/update needs to happen but can't (e.g. if github is not reachable).

* thirdparty: add no-OS library submodule

Adds a submodule for https://github.com/analogdevicesinc/no-OS/, pinned
at commit 0bba46e.

* thirdparty: patch and build libad936x

Add cmake file for libad936x

Move our local mods into patch files

* host: libbladeRF: transition to libad936x

Transitions libbladeRF (particularly bladerf2.c) to use the libad936x
package, compiled separately.

This also adds ad936x.h, a driver header file that contains the
necessary things from libad936x.  This is cleaner than just importing
ad9361_api.h, due to the significant dependency/include challenges that
ensue...

* host: fix up libad936x build

Don't use ExternalProject, instead just add it as a subdirectory

Create a FindPatcher.cmake for the patch-or-git selector

Clean up and streamline the ad936x cmakelists

Clean up libbladeRF cmakelist formatting

* thirdparty: fix no-OS patch 0003

* host: ad936x: fixup build errors/warnings on macOS

* thirdparty/adi: patch to chop out ad9361_parse_fir

ad9361_parse_fir refers to sscanf, which is not readily available in the
Nios II library. We don't use this function, so it can go.

* libbladeRF: remove vestigial adi files

* debian: rm thirdparty ADI tree from license file

* host: thirdparty: fix git package handling

* host: thirdparty/ad936x: specify patches in order

It turns out that there's no guarantee that file(GLOB)
will output the patch files in the alphabetical order.

* Revert "debian: rm thirdparty ADI tree from license file"

This reverts commit 36cf335c0e.

* debian: update path in ADI copyright
2018-11-12 18:13:58 -05:00

42 lines
1.1 KiB
CMake

if(DEFINED __INCLUDED_BLADERF_FIND_PATCHER)
return()
endif()
set(__INCLUDED_BLADERF_FIND_PATCHER TRUE)
# Look for the packages we want
find_package(Patch QUIET)
find_package(Git QUIET)
# Work around cross-platform case sensitivity issues
if(PATCH_FOUND)
set(Patch_FOUND ${PATCH_FOUND})
if (PATCH_EXECUTABLE)
set(Patch_EXECUTABLE ${PATCH_EXECUTABLE})
endif()
endif()
if(GIT_FOUND)
set(Git_FOUND ${GIT_FOUND})
if (GIT_EXECUTABLE)
set(Git_EXECUTABLE ${GIT_EXECUTABLE})
endif()
endif()
# patch is preferred, but git-apply is also okay.
if(Patch_FOUND)
set(Patcher_FOUND TRUE)
set(Patcher_EXECUTABLE ${Patch_EXECUTABLE})
elseif(Git_FOUND)
set(Patcher_FOUND TRUE)
set(Patcher_EXECUTABLE ${Git_EXECUTABLE};--bare;apply;-)
else()
set(Patcher_FOUND FALSE)
endif()
if(NOT Patcher_FOUND AND Patcher_FIND_REQUIRED)
message(FATAL_ERROR "FindPatcher: Could not find either 'patch' or 'git'!")
endif()
if(Patcher_FOUND AND NOT Patcher_FIND_QUIETLY)
message(STATUS "FindPatcher: found ${Patcher_EXECUTABLE}")
endif()