From 6defa99b3421d72f8740095ba8f03e586db85324 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Mon, 9 May 2016 10:23:19 -0500 Subject: [PATCH] Use udunits package for units conversions Changed the include for udunits to #include to work on all platforms. Added the include directory /usr/include/udunits2 for Linux. refs #231 --- include/trick/UdUnits.hh | 2 +- include/trick/swig/swig_int_templates.hh | 2 +- share/trick/makefiles/config_Linux.mk | 3 +++ trick_source/codegen/Interface_Code_Gen/FieldDescription.hh | 2 +- trick_source/codegen/Interface_Code_Gen/makefile | 1 + trick_source/trick_swig/swig_convert_units.cpp | 2 +- trick_source/trick_swig/units_attach.i | 2 +- 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/trick/UdUnits.hh b/include/trick/UdUnits.hh index 8f73fc5c..1ebf98e6 100644 --- a/include/trick/UdUnits.hh +++ b/include/trick/UdUnits.hh @@ -2,7 +2,7 @@ #ifndef UDUNITS_HH #define UDUNITS_HH -#include +#include #include namespace Trick { diff --git a/include/trick/swig/swig_int_templates.hh b/include/trick/swig/swig_int_templates.hh index eae4402e..14657be0 100644 --- a/include/trick/swig/swig_int_templates.hh +++ b/include/trick/swig/swig_int_templates.hh @@ -7,7 +7,7 @@ #define SWIG_INT_TEMPLATES_HH #include "trick/UdUnits.hh" -#include +#include template< class S , typename T > static int convert_and_set( T & output , void * my_argp , std::string to_units ) { int ret = 0 ; diff --git a/share/trick/makefiles/config_Linux.mk b/share/trick/makefiles/config_Linux.mk index b91fe69b..50f26b7a 100644 --- a/share/trick/makefiles/config_Linux.mk +++ b/share/trick/makefiles/config_Linux.mk @@ -64,3 +64,6 @@ ifeq "" "c++11" TRICK_ADDITIONAL_CXXFLAGS += -std=c++11 -D_HAVE_STL_RANDOM endif +# Additional include directory for udunits. +TRICK_ADDITIONAL_CXXFLAGS += -I/usr/include/udunits2 + diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh index 097b8e96..228cc5c7 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh @@ -6,7 +6,7 @@ #include #include -#include +#include #include "ConstructValues.hh" #include "clang/Basic/Specifiers.h" diff --git a/trick_source/codegen/Interface_Code_Gen/makefile b/trick_source/codegen/Interface_Code_Gen/makefile index e50f840b..76c55f1b 100644 --- a/trick_source/codegen/Interface_Code_Gen/makefile +++ b/trick_source/codegen/Interface_Code_Gen/makefile @@ -43,6 +43,7 @@ CXXFLAGS += -std=c++11 # Fedora 21 adds -ledit as a system lib, but it isn't installed, or required. CLANGLIBS += $(filter-out -ledit,$(shell $(LLVM_HOME)/bin/llvm-config --system-libs)) endif +CXXFLAGS += -I/usr/include/udunits2 endif ifeq ($(TRICK_HOST_TYPE),Darwin) diff --git a/trick_source/trick_swig/swig_convert_units.cpp b/trick_source/trick_swig/swig_convert_units.cpp index 6e1f4782..213d7ba5 100644 --- a/trick_source/trick_swig/swig_convert_units.cpp +++ b/trick_source/trick_swig/swig_convert_units.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include "trick/Unit.hh" #include "trick/UdUnits.hh" diff --git a/trick_source/trick_swig/units_attach.i b/trick_source/trick_swig/units_attach.i index 286d8c5a..504b1b61 100644 --- a/trick_source/trick_swig/units_attach.i +++ b/trick_source/trick_swig/units_attach.i @@ -6,7 +6,7 @@ %inline %{ #include -#include +#include #include "trick/swig/swig_double.hh" std::string map_trick_units_to_udunits( std::string orig_units ) ;