upm_version: Added get version functionality for UPM as provided by MRAA

* Renamed version.c to version.hpp
    * Updated CMakelist file
    * Updated upm.i file to support version
    * Updated/modified src Cmakelists to support base upm and wrapper dependency

Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
This commit is contained in:
sisinty sasmita patra 2017-04-19 13:49:17 -07:00
parent 5cc4e2120a
commit b2aa2515b0
5 changed files with 22 additions and 19 deletions

View File

@ -417,7 +417,10 @@ endif()
# UPM common headers # UPM common headers
set (UPM_COMMON_HEADER_DIRS set (UPM_COMMON_HEADER_DIRS
${CMAKE_HOME_DIRECTORY}/include ${CMAKE_HOME_DIRECTORY}/include
${CMAKE_HOME_DIRECTORY}/include/fti) ${CMAKE_HOME_DIRECTORY}/include/fti
${CMAKE_BINARY_DIR}/src)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/src/version.hpp @ONLY)
# UPM source # UPM source
add_subdirectory (src) add_subdirectory (src)

View File

@ -1,4 +0,0 @@
#include "version.h"
const char* gVERSION = "@VERSION@";
const char* gVERSION_SHORT = "@VERSION_SHORT@";

View File

@ -0,0 +1,6 @@
#include <string>
inline std::string getVersion()
{
return "@upm_VERSION_STRING@";
}

View File

@ -117,7 +117,7 @@ macro(_upm_swig_python)
# wrapper generation. Get them manually and add them here. # wrapper generation. Get them manually and add them here.
_get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. include_directories (${UPM_COMMON_HEADER_DIRS}
${DEPEND_DIRS}) ${DEPEND_DIRS})
set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON) set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON)
@ -230,7 +230,7 @@ macro(upm_swig_node)
_get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS) _get_target_dependency_interface_include_dirs(${libname} DEPEND_DIRS)
include_directories ( include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/.. ${UPM_COMMON_HEADER_DIRS}
${DEPEND_DIRS} ${DEPEND_DIRS}
) )
@ -289,7 +289,7 @@ macro(upm_swig_java)
include_directories ( include_directories (
${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2} ${JAVA_INCLUDE_PATH2}
${CMAKE_CURRENT_SOURCE_DIR}/.. ${UPM_COMMON_HEADER_DIRS}
${DEPEND_DIRS} ${DEPEND_DIRS}
) )
@ -476,12 +476,6 @@ function (UPM_MIXED_MODULE_INIT)
# Make sure REQUIRES is a list # Make sure REQUIRES is a list
separate_arguments(UPM_MIXED_MODULE_INIT_REQUIRES) separate_arguments(UPM_MIXED_MODULE_INIT_REQUIRES)
# Always add the common header dirs to the includes list, even if we
# end up only building a C++ module. This is needed for cases where
# a C++ only driver depends on a mixed C++/C driver.
include_directories (${UPM_COMMON_HEADER_DIRS}
${CMAKE_SOURCE_DIR}/src/utilities)
# Always build C libs first # Always build C libs first
if (UPM_MIXED_MODULE_INIT_C_SRC) if (UPM_MIXED_MODULE_INIT_C_SRC)
set (libname ${UPM_MIXED_MODULE_INIT_NAME}) set (libname ${UPM_MIXED_MODULE_INIT_NAME})
@ -510,11 +504,6 @@ function (UPM_MIXED_MODULE_INIT)
target_link_libraries (${libname} utilities-c) target_link_libraries (${libname} utilities-c)
endif() endif()
# Add include directories for C
target_include_directories (${libname} PUBLIC
${UPM_COMMON_HEADER_DIRS}
${CMAKE_SOURCE_DIR}/src/utilities)
## "export" the logical C lib target for the calling module's ## "export" the logical C lib target for the calling module's
## CMakeLists.txt ## CMakeLists.txt
set (libnamec ${libname} PARENT_SCOPE) set (libnamec ${libname} PARENT_SCOPE)
@ -561,6 +550,10 @@ function(upm_module_init)
# Create the target library from src/hdrs # Create the target library from src/hdrs
add_library (${libname} SHARED ${module_src} ${module_hpp}) add_library (${libname} SHARED ${module_src} ${module_hpp})
target_include_directories (${libname} PUBLIC
${UPM_COMMON_HEADER_DIRS}
${CMAKE_SOURCE_DIR}/src/utilities)
# Specify the current source directory as an INTERFACE include dir. # Specify the current source directory as an INTERFACE include dir.
# This allows for transitive header dependencies via target_link_libraries # This allows for transitive header dependencies via target_link_libraries
target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -2,6 +2,11 @@
%include "stdint.i" %include "stdint.i"
%include "upm_exception.i" %include "upm_exception.i"
%{
#include "version.hpp"
%}
%include "version.hpp"
%apply int { speed_t }; %apply int { speed_t };
%apply int { mraa_result_t }; %apply int { mraa_result_t };
%apply int { mraa::Result }; %apply int { mraa::Result };