Skip to content

Commit d90ac49

Browse files
authored
Merge pull request #40 from raymanfx/fedora
Prepare for Fedora packaging
2 parents c8bfa81 + 306565d commit d90ac49

File tree

3 files changed

+62
-49
lines changed

3 files changed

+62
-49
lines changed

CMakeLists.txt

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
cmake_minimum_required(VERSION 3.1)
1414
project (openpnp-capture)
15+
set(OPENPNP_CAPTURE_LIB_VERSION "0.0.20" CACHE STRING "openpnp-capture library version")
16+
set(OPENPNP_CAPTURE_LIB_SOVERSION "0.0.20" CACHE STRING "openpnp-capture library soversion")
1517

1618
# make sure the libjpegturbo is compiled with the
1719
# position independent flag -fPIC
@@ -56,6 +58,17 @@ endif(CMAKE_BUILD_TYPE MATCHES Release)
5658
# add include directory
5759
include_directories(include)
5860

61+
# create our capture library
62+
add_library(openpnp-capture SHARED common/libmain.cpp
63+
common/context.cpp
64+
common/logging.cpp
65+
common/stream.cpp)
66+
67+
# define common properties
68+
set_target_properties(openpnp-capture PROPERTIES
69+
VERSION ${OPENPNP_CAPTURE_LIB_VERSION}
70+
SOVERSION ${OPENPNP_CAPTURE_LIB_SOVERSION})
71+
5972
IF (WIN32)
6073
# build with static runtime rather than DLL based so that we
6174
# don't have to distribute it
@@ -69,15 +82,8 @@ IF (WIN32)
6982
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
7083

7184
# add files for WIN32
72-
set (SOURCE common/libmain.cpp
73-
common/context.cpp
74-
common/logging.cpp
75-
common/stream.cpp
76-
win/platformcontext.cpp
77-
win/platformstream.cpp)
78-
79-
# create the library
80-
add_library(openpnp-capture SHARED ${SOURCE})
85+
target_sources(openpnp-capture PRIVATE win/platformcontext.cpp
86+
win/platformstream.cpp)
8187

8288
# add windows-specific test application
8389
add_subdirectory(win/tests)
@@ -86,17 +92,9 @@ ELSEIF(APPLE)
8692
# set the platform identification string
8793
add_definitions(-D__PLATFORM__="OSX ${COMPILERBITS}")
8894

89-
set (SOURCE common/libmain.cpp
90-
common/context.cpp
91-
common/logging.cpp
92-
common/stream.cpp
93-
mac/platformcontext.mm
94-
mac/platformstream.mm
95-
mac/uvcctrl.mm)
96-
97-
98-
# create the library
99-
add_library(openpnp-capture SHARED ${SOURCE})
95+
target_sources(openpnp-capture PRIVATE mac/platformcontext.mm
96+
mac/platformstream.mm
97+
mac/uvcctrl.mm)
10098

10199
# include OS X specific frameworks
102100
target_link_libraries(openpnp-capture
@@ -112,44 +110,59 @@ ELSEIF(APPLE)
112110
add_subdirectory(mac/tests)
113111

114112
ELSEIF(UNIX)
115-
116-
# compile libjpeg-turbo for MJPEG decoding support
117-
# right now, we need to disable SIMD because it
118-
# causes a compile problem.. we need to fix this
119-
# later...
120-
121-
set(ENABLE_SHARED OFF)
122-
set(WITH_SIMD OFF)
123-
add_subdirectory(linux/contrib/libjpeg-turbo-dev)
113+
# install path resolving
114+
include(GNUInstallDirs)
124115

125116
# set the platform identification string
126117
add_definitions(-D__PLATFORM__="Linux ${COMPILERBITS}")
127118

128-
set (SOURCE common/libmain.cpp
129-
common/context.cpp
130-
common/logging.cpp
131-
common/stream.cpp
132-
linux/platformcontext.cpp
133-
linux/platformstream.cpp
134-
linux/mjpeghelper.cpp
135-
linux/yuvconverters.cpp)
119+
target_sources(openpnp-capture PRIVATE linux/platformcontext.cpp
120+
linux/platformstream.cpp
121+
linux/mjpeghelper.cpp
122+
linux/yuvconverters.cpp)
136123

137124
# force include directories for libjpeg-turbo
138125
include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/linux/contrib/libjpeg-turbo-dev")
139-
140-
# create our capture library
141-
add_library(openpnp-capture SHARED ${SOURCE})
142126

143127
# add pthreads library
144128
set(THREADS_PREFER_PTHREAD_FLAG ON)
145129
find_package(Threads REQUIRED)
146-
target_link_libraries(openpnp-capture Threads::Threads)
147-
148-
# add turbojpeg-static library
149-
target_link_libraries(openpnp-capture turbojpeg-static)
130+
target_link_libraries(openpnp-capture PUBLIC Threads::Threads)
131+
132+
# add turbojpeg library
133+
find_package(PkgConfig REQUIRED)
134+
pkg_search_module(TurboJPEG libturbojpeg)
135+
if( TurboJPEG_FOUND )
136+
link_directories(${TurboJPEG_LIBDIR})
137+
target_include_directories(openpnp-capture PUBLIC ${TurboJPEG_INCLUDE_DIRS})
138+
target_link_libraries(openpnp-capture PUBLIC ${TurboJPEG_LIBRARIES})
139+
else()
140+
# compile libjpeg-turbo for MJPEG decoding support
141+
# right now, we need to disable SIMD because it
142+
# causes a compile problem.. we need to fix this
143+
# later...
144+
set(ENABLE_SHARED OFF)
145+
set(WITH_SIMD OFF)
146+
set(TurboJPEG_LIBRARIES turbojpeg-static)
147+
add_subdirectory(linux/contrib/libjpeg-turbo-dev)
148+
target_link_libraries(openpnp-capture PRIVATE ${TurboJPEG_LIBRARIES})
149+
endif()
150150

151151
# add linux-specific test application
152152
add_subdirectory(linux/tests)
153153

154+
# install lib and headers
155+
install(FILES include/openpnp-capture.h
156+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
157+
COMPONENT headers)
158+
install(TARGETS openpnp-capture EXPORT openpnp-capture
159+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
160+
COMPONENT libraries)
161+
162+
# add cmake install target
163+
install(EXPORT openpnp-capture
164+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openpnp-capture
165+
COMPONENT libraries)
166+
154167
ENDIF()
155168

include/openpnp-capture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ typedef uint32_t CapFormatID; ///< format identifier 0 .. numFormats
8888

8989
typedef uint32_t CapPropertyID; ///< property ID (exposure, zoom, focus etc.)
9090

91-
struct CapFormatInfo
91+
typedef struct
9292
{
9393
uint32_t width; ///< width in pixels
9494
uint32_t height; ///< height in pixels
9595
uint32_t fourcc; ///< fourcc code (platform dependent)
9696
uint32_t fps; ///< frames per second
9797
uint32_t bpp; ///< bits per pixel
98-
};
98+
} CapFormatInfo;
9999

100100
#define CAPRESULT_OK 0
101101
#define CAPRESULT_ERR 1

linux/tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include_directories(../include ..)
2121
add_executable(openpnp-capture-test ${SOURCE})
2222

2323
target_link_libraries(openpnp-capture-test openpnp-capture)
24-
target_link_libraries(openpnp-capture-test turbojpeg-static)
24+
target_link_libraries(openpnp-capture-test ${TurboJPEG_LIBRARIES})
2525

2626
########################################################
2727
### GTK test application
@@ -41,5 +41,5 @@ set (SOURCE2 gtkmain.cpp ../../common/logging.cpp)
4141
add_executable(oc-gtk ${SOURCE2})
4242

4343
target_link_libraries(oc-gtk openpnp-capture)
44-
target_link_libraries(oc-gtk turbojpeg-static)
45-
target_link_libraries(oc-gtk ${GTK3_LIBRARIES})
44+
target_link_libraries(oc-gtk ${TurboJPEG_LIBRARIES})
45+
target_link_libraries(oc-gtk ${GTK3_LIBRARIES})

0 commit comments

Comments
 (0)