Skip to content

Commit a8feb15

Browse files
committed
Bring tcam-firmware-update into a publishable state
1 parent c157ceb commit a8feb15

File tree

7 files changed

+431
-18
lines changed

7 files changed

+431
-18
lines changed

CMakeLists.txt

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,37 @@ cmake_minimum_required(VERSION 3.2)
1818
#Name your project here
1919
project(tcam-firmware-update)
2020

21+
set( default_build_type "Release" )
2122

22-
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
23-
SET(CMAKE_INSTALL_PREFIX "/usr/" CACHE PATH "Common prefix for all installed files." FORCE)
24-
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
23+
# Set a default build type if none was specified
24+
# Override the default by specifying default_build_type
25+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
26+
if( NOT default_build_type )
27+
set( default_build_type "RelWithDebInfo" )
28+
endif()
29+
message(
30+
STATUS "Setting build type to '${default_build_type}' as none was specified.")
31+
set(CMAKE_BUILD_TYPE
32+
${default_build_type}
33+
CACHE STRING "Choose the type of build." FORCE)
34+
# Set the possible values of build type for cmake-gui, ccmake
35+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
36+
"MinSizeRel" "RelWithDebInfo")
37+
else()
38+
message( STATUS "Current CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" )
39+
endif()
40+
41+
set(TCAM_FW_VERSION_MAJOR 1)
42+
set(TCAM_FW_VERSION_MINOR 0)
43+
set(TCAM_FW_VERSION_PATCH 0)
44+
45+
set(TCAM_FW_VERSION "${TCAM_FW_VERSION_MAJOR}.${TCAM_FW_VERSION_MINOR}.${TCAM_FW_VERSION_PATCH}" CACHE STRING "Version number")
46+
47+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
48+
set(CMAKE_INSTALL_PREFIX "/usr/" CACHE PATH "Common prefix for all installed files." FORCE)
49+
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
50+
51+
set(CMAKE_INSTALL_PREFIX "/")
2552

2653
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
2754

@@ -31,9 +58,29 @@ set(TCAM_FW_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
3158
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TCAM_FW_BINARY_DIR}/bin)
3259
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${TCAM_FW_BINARY_DIR}/lib)
3360

34-
find_package(libusb-1.0 REQUIRED QUIET)
35-
find_package(LibZip REQUIRED QUIET)
61+
find_package(libusb-1.0 REQUIRED)
62+
find_package(LibZip REQUIRED)
3663

3764
add_subdirectory(external/PugiXml EXCLUDE_FROM_ALL)
3865

3966
add_subdirectory(src)
67+
68+
install(DIRECTORY firmware DESTINATION ${CMAKE_INSTALL_PREFIX})
69+
70+
include(CPackComponent)
71+
72+
set(CPACK_SET_DESTDIR "on")
73+
set(CPACK_GENERATOR "TGZ")
74+
75+
set(CPACK_PACKAGE_VERSION_MAJOR "${TCAM_FW_VERSION_MAJOR}")
76+
set(CPACK_PACKAGE_VERSION_MINOR "${TCAM_FW_VERSION_MINOR}")
77+
set(CPACK_PACKAGE_VERSION_PATCH "${TCAM_FW_VERSION_PATCH}")
78+
79+
include(package-name)
80+
81+
set(CPACK_PACKAGE_NAME "tcam-firmware-upload")
82+
create_package_name(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}" "${TCAM_FW_VERSION}")
83+
84+
85+
# always last
86+
include(CPack)

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ This tool allows you to update the firmware of your TIS USB camera under Linux.
1111
List all available cameras:
1212

1313
```
14-
firmware-update -l
14+
tcam-firmware-update -l
1515
```
1616

1717
Get information about a single camera:
1818

1919
```
20-
firmware-update -id <serial number>
20+
tcam-firmware-update -id <serial number>
2121
```
2222

2323
Apply firmware
2424

2525
```
26-
firmware-update -ud <serial number> -f firmware-file
26+
tcam-firmware-update -ud <serial number> -f firmware-file
2727
```
2828

2929
Switch camera to UVC/proprietary mode
3030

3131
```
32-
firmware-update -d <serialnumber> -m uvc
33-
firmware-update -d <serialnumber> -m proprietary
32+
tcam-firmware-update -d <serialnumber> -m uvc
33+
tcam-firmware-update -d <serialnumber> -m proprietary
3434
```
3535

3636
Switching to uvc mode is only necessary for USB2 cameras.
@@ -56,6 +56,7 @@ Required dependencies are:
5656

5757
- libusb-1.0
5858
- libzip
59+
- libudev
5960

6061
For compilation additional dev packages may be required.
6162

@@ -68,6 +69,10 @@ cmake ..
6869
make
6970
```
7071

72+
Do not call `make install`.
73+
tcam-firmware-update is not intended for system wide use.
74+
75+
7176
# License
7277

7378
tcam-firmware-update is released under the Apache 2.0 license.

cmake/FindUDev.cmake

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# razor-de: Configure libudev environment
2+
#
3+
# UDEV_FOUND - system has a libudev
4+
# UDEV_INCLUDE_DIR - where to find header files
5+
# UDEV_LIBRARIES - the libraries to link against udev
6+
# UDEV_STABLE - it's true when is the version greater or equals to 143 - version when the libudev was stabilized in its API
7+
#
8+
# copyright (c) 2011 Petr Vanek <[email protected]>
9+
# Redistribution and use is allowed according to the terms of the BSD license.
10+
#
11+
12+
FIND_PATH(
13+
UDEV_INCLUDE_DIR
14+
libudev.h
15+
/usr/include
16+
/usr/local/include
17+
${UDEV_PATH_INCLUDES}
18+
)
19+
20+
FIND_LIBRARY(
21+
UDEV_LIBRARIES
22+
NAMES udev libudev
23+
PATHS
24+
/lib/${LIB_SUFFIX}
25+
/usr/lib${LIB_SUFFIX}
26+
/usr/local/lib${LIB_SUFFIX}
27+
${UDEV_PATH_LIB}
28+
)
29+
30+
IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
31+
SET(UDEV_FOUND "YES")
32+
execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
33+
# retvale is 0 of the condition is "true" so we need to negate the value...
34+
if (UDEV_STABLE)
35+
set(UDEV_STABLE 0)
36+
else (UDEV_STABLE)
37+
set(UDEV_STABLE 1)
38+
endif (UDEV_STABLE)
39+
40+
ENDIF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
41+
42+
IF (NOT UDev_FIND_QUIETLY)
43+
IF (UDEV_FOUND)
44+
MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
45+
MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}")
46+
ELSE (UDEV_FOUND)
47+
MESSAGE(STATUS "UDev not found.")
48+
MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
49+
MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}")
50+
MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
51+
MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}")
52+
IF (UDev_FIND_REQUIRED)
53+
MESSAGE(FATAL_ERROR "Could not find UDev library")
54+
ENDIF (UDev_FIND_REQUIRED)
55+
ENDIF (UDEV_FOUND)
56+
ENDIF (NOT UDev_FIND_QUIETLY)

cmake/Findlibusb-1.0.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
6161

6262
find_library(LIBUSB_1_LIBRARY
6363
NAMES
64-
usb-1.0 usb
65-
PATHS
66-
/usr/lib
67-
/usr/local/lib
68-
/opt/local/lib
69-
/sw/lib
64+
libusb-1.0.a
7065
)
7166

7267
set(LIBUSB_1_INCLUDE_DIRS

cmake/git-helper.cmake

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Copyright 2018 The Imaging Source Europe GmbH
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#
16+
# Convenience functions for accessing git information in cmake
17+
#
18+
19+
20+
# git_is_repository
21+
# verifies that cmake is in a git repository
22+
# useful when people use the 'download as zip' functionality from github, et al
23+
# sets given argument to TRUE if git is used, otherwise it will be set to FALSE
24+
function (git_is_repository is_repo)
25+
26+
execute_process(
27+
COMMAND git rev-parse --git-dir
28+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
29+
OUTPUT_VARIABLE FUNC_ROOT_DIR
30+
ERROR_QUIET
31+
)
32+
33+
if (FUNC_ROOT_DIR)
34+
set(${is_repo} TRUE PARENT_SCOPE)
35+
else ()
36+
set(${is_repo} FALSE PARENT_SCOPE)
37+
endif (FUNC_ROOT_DIR)
38+
39+
endfunction (git_is_repository)
40+
41+
# git_commit_hash
42+
# fills the given argument with the hash of the current commit
43+
#
44+
function (git_commit_hash return_value)
45+
execute_process(
46+
COMMAND git log -1 --format=%h
47+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
48+
OUTPUT_VARIABLE GIT_COMMIT_HASH
49+
OUTPUT_STRIP_TRAILING_WHITESPACE
50+
ERROR_QUIET
51+
)
52+
53+
if (GIT_COMMIT_HASH)
54+
set(${return_value} "${GIT_COMMIT_HASH}" PARENT_SCOPE)
55+
endif (GIT_COMMIT_HASH)
56+
57+
endfunction (git_commit_hash)
58+
59+
# git_commit_count
60+
# fills the given argument with the number of commits on this branch
61+
function (git_commit_count return_value)
62+
63+
execute_process(
64+
COMMAND git rev-list --count HEAD
65+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
66+
OUTPUT_VARIABLE GIT_COMMIT_COUNT
67+
OUTPUT_STRIP_TRAILING_WHITESPACE
68+
ERROR_QUIET
69+
)
70+
71+
if (GIT_COMMIT_COUNT)
72+
set(${return_value} "${GIT_COMMIT_COUNT}" PARENT_SCOPE)
73+
endif (GIT_COMMIT_COUNT)
74+
75+
endfunction (git_commit_count)
76+
77+
# git_commit_tag
78+
# fills the given argument with the tag the current commit has
79+
function (git_commit_tag return_value)
80+
execute_process(
81+
COMMAND git describe --exact-match HEAD
82+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
83+
OUTPUT_VARIABLE GIT_TAG
84+
ERROR_VARIABLE GIT_TAG_ERROR
85+
OUTPUT_STRIP_TRAILING_WHITESPACE
86+
ERROR_QUIET
87+
)
88+
89+
if (GIT_TAG)
90+
set(${return_value} "${GIT_TAG}" PARENT_SCOPE)
91+
endif (GIT_TAG)
92+
93+
endfunction (git_commit_tag)
94+
95+
# git_branch
96+
# fills the given argument with the name of the current branch
97+
#
98+
function (git_branch return_value)
99+
execute_process(
100+
COMMAND git rev-parse --abbrev-ref HEAD
101+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
102+
OUTPUT_VARIABLE GIT_BRANCH
103+
OUTPUT_STRIP_TRAILING_WHITESPACE
104+
ERROR_QUIET
105+
)
106+
107+
if (GIT_BRANCH)
108+
set(${return_value} "${GIT_BRANCH}" PARENT_SCOPE)
109+
endif (GIT_BRANCH)
110+
111+
endfunction (git_branch)
112+
113+
# defines the following variables in the parent scope
114+
# GIT_REPO_PRESENT
115+
# GIT_COMMIT_HASH
116+
# GIT_COMMIT_COUNT
117+
# GIT_TAG
118+
# GIT_BRANCH
119+
#
120+
# the variables will not defined should error occur or should
121+
# the project not exist within a git repo
122+
#
123+
function (find_git_settings)
124+
git_is_repository( repo_present )
125+
if( repo_present )
126+
set(GIT_REPO_PRESENT ${repo_present} PARENT_SCOPE)
127+
128+
git_commit_hash(hash)
129+
if (hash)
130+
set(GIT_COMMIT_HASH "${hash}" PARENT_SCOPE)
131+
endif (hash)
132+
133+
git_commit_count(count)
134+
if (count)
135+
set(GIT_COMMIT_COUNT "${count}" PARENT_SCOPE)
136+
endif (count)
137+
138+
git_commit_tag(tag)
139+
if (tag)
140+
set(GIT_TAG "${tag}" PARENT_SCOPE)
141+
endif (tag)
142+
143+
git_branch(branch)
144+
if (branch)
145+
set(GIT_BRANCH "${branch}" PARENT_SCOPE)
146+
endif (branch)
147+
148+
endif( repo_present )
149+
endfunction ()

0 commit comments

Comments
 (0)