cmake: Dependency refactoring for includes and libs

This commit attempts to use a more cmake-friendly approach when
handling inter-target dependencies.  A combination of macros and
include_directories usage provided overzealous compile -I/blah
entries which equates to large catch-all build commands.  For
example, the last CXX target contains include directories for nearly
all preceeding targets (~190).  Library dependencies were also often
wrong or missing.

    * Removed nearly all used of include_directories (swig cmake
      commands still appear to need these for generating the swig
      command line)
    * Updated usage of target_link_libraries in upm_module_init,
      also changed to using target_include_directories per target.
      This greatly simplifies upm/mixed_module_init usage for libraries
      which depend on other libraries (in this project).

        example (src/tb7300/CMakeLists.txt)
            old:
                 # upm-libbacnetmstp will bring in libbacnet, I hope
                 set (reqlibname "upm-bacnetmstp")
                 include_directories(${BACNET_INCLUDE_DIRS})
                 include_directories("../bacnetmstp")
                 upm_module_init()
                 upm_target_link_libraries(${libname} bacnetmstp)
            new:
                 upm_module_init(bacnetmstp)

      The reason here, is that tb7300 depends on bacnetmstp, which
      depends on BACNET includes/libs, so tb7300 gets the headers and
      libraries transitively via its dependency on bacnetmstp.
    * Updated pkg-config .pc file generation flow to reflect changes
      with dependencies.
    * Create a real target for the interfaces (CXX abstract sensor
      classes).  Renamed the directory from 'upm/src/upm' to
      'upm/src/interfaces'  Also changed the install location of the
      interface headers to include/upm/interfaces.  Updated interface
      header usage to reflect this.
    * Updated a few sensor libs to use fwd declarations for mraa.
      Ideally the UPM libs would do more of this which eases the
      burden on anyone building on top of the sensor libraries since
      they would not need to know about mraa headers.
    * Fixed examples which use symbols not defined in local includes

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2017-01-30 18:14:48 -08:00
parent 7f0e03b0e3
commit d345006c03
97 changed files with 326 additions and 202 deletions

View File

@ -2,7 +2,7 @@ set (libname "ads1x15")
set (libdescription "Analog to digital converter")
set (module_src ${libname}.cxx ads1115.cxx ads1015.cxx)
set (module_hpp ${libname}.hpp ads1115.hpp ads1015.hpp)
upm_module_init()
upm_module_init(interfaces)
compiler_flag_supported(CXX is_supported -Wno-overloaded-virtual)
if (is_supported)
target_compile_options(${libname} PUBLIC -Wno-overloaded-virtual)

View File

@ -21,7 +21,11 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include "ads1015.hpp"
#include "mraa/i2c.hpp"
using namespace upm;

View File

@ -26,7 +26,7 @@
#pragma once
#include "ads1x15.hpp"
#include "upm/iADC.hpp"
#include "interfaces/iADC.hpp"
#define ADS1015_VREF 2.048

View File

@ -24,6 +24,7 @@
#include "ads1x15.hpp"
#include "mraa/i2c.hpp"
#include <unistd.h>
#include <syslog.h>

View File

@ -26,8 +26,8 @@
#include <iostream>
#include <string>
#include "mraa.hpp"
#include "mraa/i2c.hpp"
namespace mraa {class I2c;}
/*=========================================================================
I2C ADDRESS/BITS
@ -419,6 +419,6 @@ namespace upm {
void updateConfigRegister(uint16_t update, bool read = false);
uint16_t swapWord(uint16_t value);
mraa::I2c* i2c;
mraa::I2c* i2c;
};}

View File

@ -8,6 +8,8 @@
#include "ads1115.hpp"
%}
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%include "ads1015.hpp"
%include "ads1115.hpp"
@ -23,4 +25,4 @@
System.exit(1);
}
}
%}
%}

View File

@ -1,6 +1,9 @@
%module jsupm_ads1x15
%include "../upm.i"
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%{
#include "ads1x15.hpp"
@ -14,4 +17,4 @@
%include "ads1115.hpp"
%{
#include "ads1115.hpp"
%}
%}

View File

@ -5,6 +5,9 @@
%feature("autodoc", "3");
%include "iModuleStatus.hpp"
%include "iADC.hpp"
%include "ads1x15.hpp"
%{
#include "ads1x15.hpp"
@ -18,4 +21,4 @@
%include "ads1115.hpp"
%{
#include "ads1115.hpp"
%}
%}