From 5252a0049e0a509508a8f331222543620db0e6d3 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sat, 2 May 2015 14:46:12 +0200 Subject: Provide version information as required by new pcilib interface --- .bzrignore | 2 ++ CMakeLists.txt | 32 +++++++++++++++++++++++++++++++- cmake/version.cmake | 12 ++++++++++++ ipecamera.pc.in | 10 ++++++++++ model.c | 5 ++++- version.h.in | 12 ++++++++++++ 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 cmake/version.cmake create mode 100644 ipecamera.pc.in create mode 100644 version.h.in diff --git a/.bzrignore b/.bzrignore index d08bc93..0a0d69c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -4,3 +4,5 @@ cmake_install.cmake CMakeCache.txt install_manifest.txt grab +ipecamera.pc +version.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bcfc15..610baa1 100644 --- a/CMakeLists.txt +++ b/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 +) diff --git a/cmake/version.cmake b/cmake/version.cmake new file mode 100644 index 0000000..9023aef --- /dev/null +++ b/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) diff --git a/ipecamera.pc.in b/ipecamera.pc.in new file mode 100644 index 0000000..6d34409 --- /dev/null +++ b/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} diff --git a/model.c b/model.c index 02a6f0c..f9a608c 100644 --- a/model.c +++ b/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, diff --git a/version.h.in b/version.h.in new file mode 100644 index 0000000..c6711a1 --- /dev/null +++ b/version.h.in @@ -0,0 +1,12 @@ +#ifndef _IPECAMERA_VERSION_H +#define _IPECAMERA_VERSION_H + +#include + +#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 */ -- cgit v1.2.3