From: Ghislain Antony Vaillant <ghisvail@gmail.com>
Date: Thu, 2 Feb 2017 16:21:52 +0000
Subject: Use the system libraries

---
 CMakeLists.txt | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0e2433..b404e5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,6 +176,37 @@ TARGET_LINK_LIBRARIES(openshot-audio
 	${JUCE_PLATFORM_SPECIFIC_LIBRARIES}
 )
 
+find_package(ZLIB REQUIRED)
+if(NOT TARGET ZLIB::ZLIB)
+        add_library(ZLIB::ZLIB SHARED IMPORTED)
+        set_target_properties(ZLIB::ZLIB PROPERTIES
+                INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}"
+                IMPORTED_LOCATION "${ZLIB_LIBRARIES}")
+endif()
+target_compile_definitions(openshot-audio PRIVATE "-DJUCE_INCLUDE_ZLIB_CODE=0")
+target_link_libraries(openshot-audio ZLIB::ZLIB)
+
+find_package(JPEG REQUIRED)
+if(NOT TARGET JPEG::JPEG)
+        add_library(JPEG::JPEG SHARED IMPORTED)
+        set_target_properties(JPEG::JPEG PROPERTIES
+                INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}"
+                IMPORTED_LOCATION "${JPEG_LIBRARIES}")
+endif()
+target_compile_definitions(openshot-audio PRIVATE "-DJUCE_INCLUDE_JPEGLIB_CODE=0")
+target_link_libraries(openshot-audio JPEG::JPEG)
+
+find_package(PNG REQUIRED)
+if(NOT TARGET PNG::PNG)
+        add_library(PNG::PNG SHARED IMPORTED)
+        set_target_properties(PNG::PNG PROPERTIES
+                INTERFACE_COMPILE_DEFINITIONS "${PNG_DEFINITIONS}"
+                INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
+                IMPORTED_LOCATION "${PNG_LIBRARIES}")
+endif()
+target_compile_definitions(openshot-audio PRIVATE "-DJUCE_INCLUDE_PNGLIB_CODE=0")
+target_link_libraries(openshot-audio PNG::PNG)
+
 # PROCESS SUB-DIRECTORIES
 add_subdirectory(src)
 
