Skip to content

Commit 103b047

Browse files
authored
Release 0.38.0 (#162)
1 parent 01f9558 commit 103b047

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+12195
-921
lines changed

.clang-format

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
---
22
BasedOnStyle: Microsoft
3-
AccessModifierOffset: '-4'
3+
AccessModifierOffset: -4
44
AlignAfterOpenBracket: Align
5-
AlignConsecutiveMacros: 'true'
6-
AlignConsecutiveAssignments: 'false'
7-
AlignConsecutiveDeclarations: 'false'
5+
AlignConsecutiveMacros: true
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
88
AlignEscapedNewlines: Right
9-
AlignOperands: 'true'
10-
AlignTrailingComments: 'true'
11-
AllowAllArgumentsOnNextLine: 'false'
12-
AllowAllConstructorInitializersOnNextLine: 'true'
13-
AllowAllParametersOfDeclarationOnNextLine: 'true'
14-
AllowShortBlocksOnASingleLine: 'false'
15-
AllowShortCaseLabelsOnASingleLine: 'false'
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllArgumentsOnNextLine: false
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: true
14+
AllowShortBlocksOnASingleLine: Never
15+
AllowShortCaseLabelsOnASingleLine: false
1616
AllowShortFunctionsOnASingleLine: None
1717
AllowShortIfStatementsOnASingleLine: Never
1818
AllowShortLambdasOnASingleLine: All
19-
AllowShortLoopsOnASingleLine: 'false'
19+
AllowShortLoopsOnASingleLine: false
2020
AlwaysBreakAfterReturnType: None
21-
AlwaysBreakBeforeMultilineStrings: 'false'
22-
AlwaysBreakTemplateDeclarations: 'Yes'
23-
BinPackArguments: 'true'
24-
BinPackParameters: 'true'
25-
BreakAfterJavaFieldAnnotations: 'true'
21+
AlwaysBreakBeforeMultilineStrings: false
22+
AlwaysBreakTemplateDeclarations: Yes
23+
BinPackArguments: true
24+
BinPackParameters: true
25+
BreakAfterJavaFieldAnnotations: true
2626
BreakConstructorInitializers: AfterColon
2727
BreakInheritanceList: AfterColon
28-
ColumnLimit: '120'
29-
CompactNamespaces: 'true'
30-
DerivePointerAlignment: 'false'
31-
DisableFormat: 'false'
32-
ExperimentalAutoDetectBinPacking: 'false'
33-
FixNamespaceComments: 'true'
28+
ColumnLimit: 120
29+
CompactNamespaces: true
30+
DerivePointerAlignment: false
31+
DisableFormat: false
32+
ExperimentalAutoDetectBinPacking: false
33+
FixNamespaceComments: true
3434
IncludeBlocks: Regroup
35-
KeepEmptyLinesAtTheStartOfBlocks: 'false'
36-
MaxEmptyLinesToKeep: '2'
35+
KeepEmptyLinesAtTheStartOfBlocks: false
36+
MaxEmptyLinesToKeep: 2
3737
NamespaceIndentation: None
3838
PointerAlignment: Left
39-
SortIncludes: 'false'
40-
SortUsingDeclarations: 'true'
41-
SpaceAfterCStyleCast: 'false'
42-
SpaceAfterLogicalNot: 'false'
43-
SpaceAfterTemplateKeyword: 'true'
44-
SpaceBeforeAssignmentOperators: 'true'
45-
SpaceBeforeCpp11BracedList: 'true'
46-
SpaceBeforeCtorInitializerColon: 'true'
39+
SortIncludes: Never
40+
SortUsingDeclarations: true
41+
SpaceAfterCStyleCast: false
42+
SpaceAfterLogicalNot: false
43+
SpaceAfterTemplateKeyword: true
44+
SpaceBeforeAssignmentOperators: true
45+
SpaceBeforeCpp11BracedList: true
46+
SpaceBeforeCtorInitializerColon: true
4747
SpaceBeforeParens: ControlStatements
48-
SpaceBeforeRangeBasedForLoopColon: 'true'
49-
SpaceInEmptyParentheses: 'false'
50-
SpacesInAngles: 'false'
51-
SpacesInCStyleCastParentheses: 'false'
52-
SpacesInContainerLiterals: 'false'
53-
SpacesInParentheses: 'false'
54-
SpacesInSquareBrackets: 'false'
48+
SpaceBeforeRangeBasedForLoopColon: true
49+
SpaceInEmptyParentheses: false
50+
SpacesInAngles: false
51+
SpacesInCStyleCastParentheses: false
52+
SpacesInContainerLiterals: false
53+
SpacesInParentheses: false
54+
SpacesInSquareBrackets: false
5555
UseTab: Never
5656
IndentWidth: 4
5757

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(libuvc
3+
VERSION 0.0.7
4+
LANGUAGES C
5+
)
6+
7+
# Additional search scripts path for libusb-1.0, libjpeg, OpenCV
8+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
9+
10+
# Xcode and Visual Studio do not using CMAKE_BUILD_TYPE cache variable
11+
# so we use Release build type only with single configuration generators.
12+
if (NOT CMAKE_CONFIGURATION_TYPES)
13+
if(NOT CMAKE_BUILD_TYPE)
14+
message(STATUS "No build type selected, default to Release")
15+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
16+
endif()
17+
endif()
18+
19+
if(NOT CMAKE_BUILD_TARGET)
20+
message(STATUS "No target type selected, default to both shared and static library")
21+
set(CMAKE_BUILD_TARGET "Both" CACHE STRING "" FORCE)
22+
endif()
23+
24+
option(BUILD_EXAMPLE "Build example program" OFF) # RSID_W10 - ON -> OFF
25+
option(BUILD_TEST "Build test program" OFF)
26+
option(ENABLE_UVC_DEBUGGING "Enable UVC debugging" OFF)
27+
28+
set(libuvc_DESCRIPTION "A cross-platform library for USB video devices")
29+
set(libuvc_URL "https://github.com/libuvc/libuvc")
30+
31+
set(SOURCES
32+
src/ctrl.c
33+
src/ctrl-gen.c
34+
src/device.c
35+
src/diag.c
36+
src/frame.c
37+
src/init.c
38+
src/stream.c
39+
src/misc.c
40+
)
41+
42+
find_package(LibUSB)
43+
44+
# JpegPkg name to differ from shipped with CMake
45+
46+
# RSID_W10: No JPEG required
47+
#find_package(JpegPkg QUIET)
48+
#if(JPEG_FOUND)
49+
# message(STATUS "Building libuvc with JPEG support.")
50+
# set(LIBUVC_HAS_JPEG TRUE)
51+
# list(APPEND SOURCES src/frame-mjpeg.c)
52+
#else()
53+
# message(WARNING "JPEG not found. libuvc will not support JPEG decoding.")
54+
#endif()
55+
56+
if(UNIX AND NOT APPLE)
57+
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
58+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
59+
find_package(Threads REQUIRED)
60+
set(threads Threads::Threads)
61+
endif()
62+
63+
# RSID_W10: Only build static
64+
set(BUILD_UVC_SHARED FALSE)
65+
set(BUILD_UVC_STATIC TRUE)
66+
set(LibUVC_STATIC TRUE)
67+
#if(${CMAKE_BUILD_TARGET} MATCHES "Shared")
68+
# set(BUILD_UVC_SHARED TRUE)
69+
#elseif(${CMAKE_BUILD_TARGET} MATCHES "Static")
70+
# set(BUILD_UVC_STATIC TRUE)
71+
#elseif(${CMAKE_BUILD_TARGET} MATCHES "Both")
72+
# set(BUILD_UVC_SHARED TRUE)
73+
# set(BUILD_UVC_STATIC TRUE)
74+
#else()
75+
# message(FATAL_ERROR "Invalid build type ${CMAKE_BUILD_TARGET}" )
76+
#endif()
77+
78+
if(BUILD_UVC_SHARED)
79+
add_library(uvc SHARED ${SOURCES})
80+
set_target_properties(uvc PROPERTIES
81+
VERSION ${libuvc_VERSION}
82+
SOVERSION ${libuvc_VERSION_MAJOR}
83+
# Exported name of target within namespace LibUVC
84+
EXPORT_NAME UVCShared
85+
)
86+
list(APPEND UVC_TARGETS uvc)
87+
if(NOT LibUVC_STATIC)
88+
add_library(LibUVC::UVC ALIAS uvc)
89+
endif()
90+
# Aliases defined here available only if project included
91+
# via addsubdirectory
92+
add_library(LibUVC::UVCShared ALIAS uvc)
93+
endif()
94+
95+
if(BUILD_UVC_STATIC)
96+
add_library(uvc_static STATIC ${SOURCES})
97+
set_target_properties(uvc_static PROPERTIES
98+
OUTPUT_NAME uvc
99+
# Exported name of target within namespace LibUVC
100+
EXPORT_NAME UVCStatic
101+
)
102+
list(APPEND UVC_TARGETS uvc_static)
103+
add_library(LibUVC::UVCStatic ALIAS uvc_static)
104+
if(LibUVC_STATIC)
105+
add_library(LibUVC::UVC ALIAS uvc_static)
106+
endif()
107+
endif()
108+
109+
configure_file(include/libuvc/libuvc_config.h.in
110+
include/libuvc/libuvc_config.h
111+
@ONLY
112+
)
113+
114+
foreach(target_name IN LISTS UVC_TARGETS)
115+
target_include_directories(${target_name}
116+
PUBLIC
117+
# Different paths for includes for build and install phase supported
118+
# via INSTALL_INTERFACE and BUILD_INTERFACE generator expressions.
119+
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
120+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
121+
$<INSTALL_INTERFACE:include>
122+
)
123+
target_link_libraries(${target_name}
124+
# libusb-1.0 used internally so we link to it privately.
125+
PRIVATE LibUSB::LibUSB ${threads}
126+
)
127+
if(JPEG_FOUND)
128+
target_link_libraries(${target_name}
129+
PRIVATE JPEG::JPEG
130+
)
131+
endif()
132+
set_target_properties(${target_name} PROPERTIES
133+
PUBLIC_HEADER "include/libuvc/libuvc.h;${CMAKE_CURRENT_BINARY_DIR}/include/libuvc/libuvc_config.h"
134+
)
135+
if(ENABLE_UVC_DEBUGGING)
136+
target_compile_definitions(${target_name}
137+
PRIVATE
138+
UVC_DEBUGGING
139+
)
140+
find_library(
141+
log-lib
142+
log
143+
)
144+
target_link_libraries(
145+
${target_name}
146+
PRIVATE
147+
${log-lib}
148+
)
149+
endif()
150+
endforeach()
151+
152+
if(BUILD_EXAMPLE)
153+
add_executable(example src/example.c)
154+
find_package(Threads)
155+
target_link_libraries(example
156+
PRIVATE
157+
LibUVC::UVC
158+
Threads::Threads
159+
)
160+
endif()
161+
162+
if(BUILD_TEST)
163+
# OpenCV defines targets with transitive dependencies not with namespaces but using opencv_ prefix.
164+
# This targets provide necessary include directories and linked flags.
165+
find_package(OpenCVPkg REQUIRED
166+
COMPONENTS
167+
opencv_core
168+
opencv_highgui
169+
)
170+
171+
add_executable(uvc_test src/test.c)
172+
target_link_libraries(uvc_test
173+
PRIVATE
174+
LibUVC::UVC
175+
opencv_core
176+
opencv_highgui
177+
)
178+
endif()
179+
180+
181+
include(GNUInstallDirs)
182+
set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/libuvc)
183+
184+
install(
185+
TARGETS ${UVC_TARGETS}
186+
EXPORT libuvcTargets
187+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
188+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
189+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
190+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
191+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libuvc
192+
)
193+
194+
install(EXPORT libuvcTargets
195+
FILE libuvcTargets.cmake
196+
NAMESPACE LibUVC::
197+
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
198+
)
199+
200+
install(FILES
201+
cmake/FindLibUSB.cmake
202+
cmake/FindJpegPkg.cmake
203+
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
204+
)
205+
206+
include(CMakePackageConfigHelpers)
207+
write_basic_package_version_file(libuvcConfigVersion.cmake
208+
COMPATIBILITY AnyNewerVersion
209+
)
210+
211+
install(FILES
212+
${CMAKE_CURRENT_BINARY_DIR}/libuvcConfigVersion.cmake
213+
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
214+
)
215+
216+
if(JPEG_FOUND)
217+
# If we have used JPEG library we need to
218+
# add linker flag for it in config file for pkgconfig
219+
set(PKGCONFIG_JPEG_LDFLAG "-ljpeg")
220+
endif()
221+
222+
configure_file(libuvc.pc.in
223+
${PROJECT_BINARY_DIR}/libuvc.pc
224+
@ONLY
225+
)
226+
227+
install(FILES
228+
${CMAKE_CURRENT_BINARY_DIR}/libuvc.pc
229+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
230+
)
231+
232+
install(FILES libuvcConfig.cmake
233+
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
234+
)
235+
236+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Software License Agreement (BSD License)
2+
3+
Copyright (C) 2010-2015 Ken Tossell
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions
8+
are met:
9+
10+
* Redistributions of source code must retain the above copyright
11+
notice, this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials provided
15+
with the distribution.
16+
* Neither the name of the author nor other contributors may be
17+
used to endorse or promote products derived from this software
18+
without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)