12
12
13
13
cmake_minimum_required (VERSION 3.1 )
14
14
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" )
15
17
16
18
# make sure the libjpegturbo is compiled with the
17
19
# position independent flag -fPIC
@@ -56,6 +58,17 @@ endif(CMAKE_BUILD_TYPE MATCHES Release)
56
58
# add include directory
57
59
include_directories (include )
58
60
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
+
59
72
IF (WIN32 )
60
73
# build with static runtime rather than DLL based so that we
61
74
# don't have to distribute it
@@ -69,15 +82,8 @@ IF (WIN32)
69
82
add_definitions (-D_CRT_SECURE_NO_WARNINGS )
70
83
71
84
# 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 )
81
87
82
88
# add windows-specific test application
83
89
add_subdirectory (win/tests )
@@ -86,17 +92,9 @@ ELSEIF(APPLE)
86
92
# set the platform identification string
87
93
add_definitions (-D__PLATFORM__= "OSX ${COMPILERBITS} " )
88
94
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 )
100
98
101
99
# include OS X specific frameworks
102
100
target_link_libraries (openpnp-capture
@@ -112,44 +110,59 @@ ELSEIF(APPLE)
112
110
add_subdirectory (mac/tests )
113
111
114
112
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 )
124
115
125
116
# set the platform identification string
126
117
add_definitions (-D__PLATFORM__= "Linux ${COMPILERBITS} " )
127
118
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 )
136
123
137
124
# force include directories for libjpeg-turbo
138
125
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} )
142
126
143
127
# add pthreads library
144
128
set (THREADS_PREFER_PTHREAD_FLAG ON )
145
129
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 ()
150
150
151
151
# add linux-specific test application
152
152
add_subdirectory (linux/tests )
153
153
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
+
154
167
ENDIF ()
155
168
0 commit comments