2424# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2525################################################################################
2626
27- # Pick up our include directories from the parent context
28- include_directories (${OPENSHOT_INCLUDE_DIRS} )
29-
30- ####### Display summary of options/dependencies ######
27+ # Collect and display summary of options/dependencies
3128include (FeatureSummary)
3229
3330################ OPTIONS ##################
@@ -36,6 +33,9 @@ option(USE_SYSTEM_JSONCPP "Use system installed JsonCpp, if found" ON)
3633option (DISABLE_BUNDLED_JSONCPP "Don't fall back to bundled JsonCpp" OFF )
3734option (ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF )
3835
36+ # Automatically process Qt classes with meta-object compiler
37+ set (CMAKE_AUTOMOC True )
38+
3939################ WINDOWS ##################
4040# Set some compiler options for Windows
4141# required for libopenshot-audio headers
@@ -90,23 +90,6 @@ FIND_PACKAGE(OpenShotAudio 0.1.8 REQUIRED)
9090# Include Juce headers (needed for compile)
9191include_directories (${LIBOPENSHOT_AUDIO_INCLUDE_DIRS} )
9292
93- ################# QT5 ###################
94- # Find QT5 libraries
95- foreach (qt_lib Qt5Widgets Qt5Core Qt5Gui Qt5Multimedia Qt5MultimediaWidgets)
96- find_package (${qt_lib} REQUIRED)
97- # Header files
98- include_directories (${${qt_lib} _INCLUDE_DIRS})
99- # Compiler definitions
100- add_definitions (${${qt_lib} _DEFINITIONS})
101- # Other CFLAGS
102- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${qt_lib} _EXECUTABLE_COMPILE_FLAGS}" )
103- # For use when linking
104- list (APPEND QT_LIBRARIES ${${qt_lib} _LIBRARIES})
105- endforeach ()
106-
107- # Manually moc Qt files
108- qt5_wrap_cpp(MOC_FILES ${QT_HEADER_FILES} )
109-
11093################# BLACKMAGIC DECKLINK ###################
11194# Find BlackMagic DeckLinkAPI libraries
11295IF (ENABLE_BLACKMAGIC)
@@ -161,73 +144,71 @@ if(ENABLE_IWYU)
161144endif ()
162145add_feature_info("IWYU (include-what-you-use)" ENABLE_IWYU "Scan all source files with 'iwyu'" )
163146
164- #### GET LIST OF EFFECT FILES ####
165- FILE (GLOB EFFECT_FILES "${CMAKE_CURRENT_SOURCE_DIR} /effects/*.cpp" )
166-
167- #### GET LIST OF QT PLAYER FILES ####
168- FILE (GLOB QT_PLAYER_FILES "${CMAKE_CURRENT_SOURCE_DIR} /Qt/*.cpp" )
169-
170- ############### SET LIBRARY SOURCE FILES #################
171- SET ( OPENSHOT_SOURCE_FILES
172- AudioBufferSource.cpp
173- AudioReaderSource.cpp
174- AudioResampler.cpp
175- CacheBase.cpp
176- CacheDisk.cpp
177- CacheMemory.cpp
178- ChunkReader.cpp
179- ChunkWriter.cpp
180- Color.cpp
181- Clip.cpp
182- ClipBase.cpp
183- Coordinate.cpp
184- CrashHandler.cpp
185- DummyReader.cpp
186- ReaderBase.cpp
187- RendererBase.cpp
188- WriterBase.cpp
189- EffectBase.cpp
190- ${EFFECT_FILES}
191- EffectInfo.cpp
192- FFmpegReader.cpp
193- FFmpegWriter.cpp
194- Fraction.cpp
195- Frame.cpp
196- FrameMapper.cpp
197- KeyFrame.cpp
198- OpenShotVersion.cpp
199- ZmqLogger.cpp
200- PlayerBase.cpp
201- Point.cpp
202- Profiles.cpp
203- QtImageReader.cpp
204- QtPlayer.cpp
205- Settings.cpp
206- Timeline.cpp
207- QtTextReader.cpp
208- QtHtmlReader.cpp
209-
210-
211- # Qt Video Player
212- ${QT_PLAYER_FILES}
213- ${MOC_FILES} )
214-
215- # ImageMagic related files
216- IF (ImageMagick_FOUND)
217- SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
218- ImageReader.cpp
219- ImageWriter.cpp
220- TextReader.cpp)
221- ENDIF (ImageMagick_FOUND)
222-
223- # BlackMagic related files
224- IF (BLACKMAGIC_FOUND)
225- SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
226- DecklinkInput.cpp
227- DecklinkReader.cpp
228- DecklinkOutput.cpp
229- DecklinkWriter.cpp)
230- ENDIF (BLACKMAGIC_FOUND)
147+ # Main library sources
148+ set (OPENSHOT_SOURCES
149+ AudioBufferSource.cpp
150+ AudioReaderSource.cpp
151+ AudioResampler.cpp
152+ CacheBase.cpp
153+ CacheDisk.cpp
154+ CacheMemory.cpp
155+ ChunkReader.cpp
156+ ChunkWriter.cpp
157+ Color.cpp
158+ Clip.cpp
159+ ClipBase.cpp
160+ Coordinate.cpp
161+ CrashHandler.cpp
162+ DummyReader.cpp
163+ ReaderBase.cpp
164+ RendererBase.cpp
165+ WriterBase.cpp
166+ EffectBase.cpp
167+ EffectInfo.cpp
168+ FFmpegReader.cpp
169+ FFmpegWriter.cpp
170+ Fraction.cpp
171+ Frame.cpp
172+ FrameMapper.cpp
173+ KeyFrame.cpp
174+ OpenShotVersion.cpp
175+ ZmqLogger.cpp
176+ PlayerBase.cpp
177+ Point.cpp
178+ Profiles.cpp
179+ QtHtmlReader.cpp
180+ QtImageReader.cpp
181+ QtPlayer.cpp
182+ QtTextReader.cpp
183+ Settings.cpp
184+ Timeline.cpp)
185+
186+ # Video effects
187+ set (EFFECTS_SOURCES
188+ effects/Bars.cpp
189+ effects/Blur.cpp
190+ effects/Brightness.cpp
191+ effects/ChromaKey.cpp
192+ effects/ColorShift.cpp
193+ effects/Crop.cpp
194+ effects/Deinterlace.cpp
195+ effects/Hue.cpp
196+ effects/Mask.cpp
197+ effects/Negate.cpp
198+ effects/Pixelate.cpp
199+ effects/Saturation.cpp
200+ effects/Shift.cpp
201+ effects/Wave.cpp)
202+
203+ # Qt video player components
204+ set (QT_PLAYER_SOURCES
205+ Qt/AudioPlaybackThread.cpp
206+ Qt/PlayerDemo.cpp
207+ Qt/PlayerPrivate.cpp
208+ Qt/VideoCacheThread.cpp
209+ Qt/VideoPlaybackThread.cpp
210+ Qt/VideoRenderer.cpp
211+ Qt/VideoRenderWidget.cpp)
231212
232213
233214# Get list of headers
@@ -238,9 +219,13 @@ SET(CMAKE_MACOSX_RPATH 0)
238219
239220############### CREATE LIBRARY #################
240221# Create shared openshot library
241- add_library (openshot SHARED
242- ${OPENSHOT_SOURCE_FILES}
243- ${headers} )
222+ add_library (openshot SHARED)
223+
224+ target_sources (openshot
225+ PRIVATE
226+ ${OPENSHOT_SOURCES} ${EFFECTS_SOURCES} ${QT_PLAYER_SOURCES}
227+ PUBLIC
228+ ${headers} )
244229
245230# Set SONAME and other library properties
246231set_target_properties (openshot
@@ -250,6 +235,34 @@ set_target_properties(openshot
250235 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX} /lib"
251236 )
252237
238+ # Add optional ImageMagic-dependent sources
239+ if (ImageMagick_FOUND)
240+ target_sources (openshot PRIVATE
241+ ImageReader.cpp
242+ ImageWriter.cpp
243+ TextReader.cpp)
244+ endif ()
245+
246+ # BlackMagic related files
247+ if (BLACKMAGIC_FOUND)
248+ target_sources (openshot PRIVATE
249+ DecklinkInput.cpp
250+ DecklinkReader.cpp
251+ DecklinkOutput.cpp
252+ DecklinkWriter.cpp)
253+ endif ()
254+
255+ # Location of our includes, both internally and when installed
256+ target_include_directories (openshot
257+ PRIVATE
258+ ${CMAKE_SOURCE_DIR} /include
259+ ${CMAKE_BINARY_DIR} /include
260+ PUBLIC
261+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include >
262+ $<BUILD_INTERFACE:${CMAKE_BINARY_DIR} /include >
263+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} /libopenshot>)
264+
265+
253266################### JSONCPP #####################
254267# Include jsoncpp headers (needed for JSON parsing)
255268if (USE_SYSTEM_JSONCPP)
@@ -288,6 +301,17 @@ if (TARGET jsoncpp_lib)
288301 target_link_libraries (openshot PUBLIC jsoncpp_lib)
289302endif ()
290303
304+ ################# QT5 ###################
305+ # Find QT5 libraries
306+ set (_qt_components Widgets Core Gui Multimedia MultimediaWidgets)
307+ find_package (Qt5 COMPONENTS ${_qt_components} REQUIRED)
308+
309+ foreach (_qt_comp IN LISTS _qt_components)
310+ if (TARGET Qt5::${_qt_comp} )
311+ target_link_libraries (openshot PUBLIC Qt5::${_qt_comp} )
312+ endif ()
313+ endforeach ()
314+
291315################### FFMPEG #####################
292316# Find FFmpeg libraries (used for video encoding / decoding)
293317FIND_PACKAGE (FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)
@@ -341,35 +365,27 @@ endif()
341365
342366
343367############### LINK LIBRARY #################
344- SET ( REQUIRED_LIBRARIES
345- ${LIBOPENSHOT_AUDIO_LIBRARIES}
346- ${QT_LIBRARIES}
347- ${PROFILER}
348- )
349-
350- IF (RESVG_FOUND)
351- list (APPEND REQUIRED_LIBRARIES ${RESVG_LIBRARIES} )
352- ENDIF (RESVG_FOUND)
368+ # Link remaining dependency libraries
369+ target_link_libraries (openshot PUBLIC
370+ ${LIBOPENSHOT_AUDIO_LIBRARIES}
371+ ${PROFILER} )
353372
373+ if (ImageMagick_FOUND)
374+ target_link_libraries (openshot PUBLIC ${ImageMagick_LIBRARIES} )
375+ endif ()
354376
355- IF (ImageMagick_FOUND )
356- list ( APPEND REQUIRED_LIBRARIES ${ImageMagick_LIBRARIES } )
357- ENDIF (ImageMagick_FOUND )
377+ if (RESVG_FOUND )
378+ target_link_libraries (openshot PUBLIC ${RESVG_LIBRARIES } )
379+ endif ( )
358380
359- IF (BLACKMAGIC_FOUND)
360- list ( APPEND REQUIRED_LIBRARIES ${BLACKMAGIC_LIBRARY_DIR} )
361- ENDIF (BLACKMAGIC_FOUND )
381+ if (BLACKMAGIC_FOUND)
382+ target_link_libraries (openshot PUBLIC ${BLACKMAGIC_LIBRARY_DIR} )
383+ endif ( )
362384
363- IF (WIN32 )
385+ if (WIN32 )
364386 # Required for exception handling on Windows
365- list (APPEND REQUIRED_LIBRARIES "imagehlp" "dbghelp" )
366- ENDIF (WIN32 )
367-
368- # Link all referenced libraries
369- target_link_libraries (openshot PUBLIC ${REQUIRED_LIBRARIES} )
370-
371- # Pick up parameters from OpenMP target and propagate
372- target_link_libraries (openshot PUBLIC OpenMP::OpenMP_CXX)
387+ target_link_libraries (openshot PUBLIC "imagehlp" "dbghelp" )
388+ endif ()
373389
374390
375391############### CLI EXECUTABLES ################
0 commit comments