Browse Source

Provide version information as required by new pcilib interface

Suren A. Chilingaryan 9 years ago
parent
commit
5252a0049e
6 changed files with 71 additions and 2 deletions
  1. 2 0
      .bzrignore
  2. 31 1
      CMakeLists.txt
  3. 12 0
      cmake/version.cmake
  4. 10 0
      ipecamera.pc.in
  5. 4 1
      model.c
  6. 12 0
      version.h.in

+ 2 - 0
.bzrignore

@@ -4,3 +4,5 @@ cmake_install.cmake
 CMakeCache.txt
 install_manifest.txt
 grab
+ipecamera.pc
+version.h

+ 31 - 1
CMakeLists.txt

@@ -13,6 +13,10 @@ pkg_check_modules(UFODECODE ufodecode>=0.3 REQUIRED)
 pkg_check_modules(PCILIB pcitool>=0.2 REQUIRED)
 exec_program("pkg-config --variable=plugindir pcitool" OUTPUT_VARIABLE PCILIB_PLUGIN_DIR)
 
+include(cmake/version.cmake)
+VERSION_TO_VARS(${IPECAMERA_VERSION} IPECAMERA_VERSION_MAJOR IPECAMERA_VERSION_MINOR IPECAMERA_VERSION_MICRO)
+
+
 add_subdirectory(apps)
 
 include_directories(
@@ -26,7 +30,7 @@ link_directories(
     ${PCILIB_LIBRARY_DIRS}
 )
 
-set(HEADERS ${HEADERS} model.h cmosis.h base.h reader.h events.h data.h private.h ipecamera.h)
+set(HEADERS ${HEADERS} model.h cmosis.h base.h reader.h events.h data.h private.h ipecamera.h version.h)
 
 add_library(ipecamera SHARED model.c cmosis.c base.c reader.c events.c data.c)
 
@@ -40,3 +44,29 @@ install(TARGETS ipecamera
     DESTINATION ${PCILIB_PLUGIN_DIR}
 )
 
+set(TARNAME "ipecamera")
+set(PACKAGE_VERSION ${IPECAMERA_VERSION})
+set(PACKAGE_NAME "${TARNAME}")
+set(PACKAGE_TARNAME "${TARNAME}")
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
+
+if(NOT DEFINED BIN_INSTALL_DIR)
+    set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+endif(NOT DEFINED BIN_INSTALL_DIR)
+
+if(NOT DEFINED LIB_INSTALL_DIR)
+    set(LIB_INSTALL_DIR "${LIB_INSTALL_DIR}")
+endif(NOT DEFINED LIB_INSTALL_DIR)
+
+if(NOT DEFINED INCLUDE_INSTALL_DIR)
+    set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
+endif(NOT DEFINED INCLUDE_INSTALL_DIR)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ipecamera.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ipecamera.pc)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+
+install(FILES 
+    ${CMAKE_CURRENT_BINARY_DIR}/ipecamera.pc 
+    DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+)

+ 12 - 0
cmake/version.cmake

@@ -0,0 +1,12 @@
+SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+")
+
+MACRO(VERSION_TO_VARS version major minor patch)
+  IF(${version} MATCHES ${VERSION_REGEX})
+    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" ${major} "${version}")
+    STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" ${minor} "${version}")
+    STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" ${patch} "${version}")
+  ELSE(${version} MATCHES ${VERSION_REGEX})
+    MESSAGE("MACRO(VERSION_TO_VARS ${version} ${major} ${minor} ${patch}")
+    MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.")
+  ENDIF(${version} MATCHES ${VERSION_REGEX})
+ENDMACRO(VERSION_TO_VARS)

+ 10 - 0
ipecamera.pc.in

@@ -0,0 +1,10 @@
+prefix=${CMAKE_INSTALL_PREFIX}
+exec_prefix=${BIN_INSTALL_DIR}
+libdir=${PCILIB_PLUGIN_DIR}
+includedir=${INCLUDE_INSTALL_DIR}
+
+Name: ${TARNAME}
+Description: IPECamera event engine for pcilib
+Version: ${PACKAGE_VERSION}
+Libs: -L${PCILIB_PLUGIN_DIR} -lipecamera
+Cflags: -I${INCLUDE_INSTALL_DIR}

+ 4 - 1
model.c

@@ -6,6 +6,7 @@
 #include "base.h"
 #include "cmosis.h"
 #include "model.h"
+#include "version.h"
 
 enum ipecamera_protocol_s {
     IPECAMERA_PROTOCOL_CMOSIS = PCILIB_REGISTER_PROTOCOL0,
@@ -13,7 +14,7 @@ enum ipecamera_protocol_s {
 
 
 static const pcilib_register_protocol_api_description_t ipecamera_cmosis_protocol_api =
-    { NULL, NULL, ipecamera_cmosis_read, ipecamera_cmosis_write };
+    { IPECAMERA_VERSION, NULL, NULL, ipecamera_cmosis_read, ipecamera_cmosis_write };
 
 /*
 static const pcilib_dma_description_t ipecamera_dma =
@@ -150,6 +151,8 @@ static const pcilib_event_data_type_description_t ipecamera_data_types[] = {
 };
 
 pcilib_event_api_description_t ipecamera_image_api = {
+    IPECAMERA_VERSION,
+
     ipecamera_init,
     ipecamera_free,
 

+ 12 - 0
version.h.in

@@ -0,0 +1,12 @@
+#ifndef _IPECAMERA_VERSION_H
+#define _IPECAMERA_VERSION_H
+
+#include <pcilib/version.h>
+
+#define IPECAMERA_VERSION_MAJOR ${IPECAMERA_VERSION_MAJOR}
+#define IPECAMERA_VERSION_MINOR ${IPECAMERA_VERSION_MINOR}
+#define IPECAMERA_VERSION_MICRO ${IPECAMERA_VERSION_MICRO}
+
+#define IPECAMERA_VERSION PCILIB_MAKE_VERSION(IPECAMERA_VERSION_MAJOR, IPECAMERA_VERSION_MINOR, IPECAMERA_VERSION_MICRO)
+
+#endif /* _IPECAMERA_VERSION_H */