From 6612ceafce0d22633157027b0e6f36a0cc9c74be Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Tue, 10 Mar 2015 18:54:42 +0100
Subject: [PATCH] ENH: add find_package() calls

---
 Superbuild/CMake/External_boost.cmake       | 18 ++++++++++++------
 Superbuild/CMake/External_curl.cmake        |  8 ++------
 Superbuild/CMake/External_expat.cmake       |  8 ++------
 Superbuild/CMake/External_fftw.cmake        |  9 +++------
 Superbuild/CMake/External_gdal.cmake        |  8 ++------
 Superbuild/CMake/External_geos.cmake        |  9 +++------
 Superbuild/CMake/External_geotiff.cmake     |  8 ++------
 Superbuild/CMake/External_itk.cmake         |  9 ++-------
 Superbuild/CMake/External_jpeg.cmake        |  8 ++------
 Superbuild/CMake/External_libkml.cmake      |  8 ++------
 Superbuild/CMake/External_muparser.cmake    |  8 ++------
 Superbuild/CMake/External_muparserx.cmake   |  8 ++------
 Superbuild/CMake/External_opencv.cmake      |  8 ++------
 Superbuild/CMake/External_openjpeg.cmake    |  9 +++------
 Superbuild/CMake/External_openthreads.cmake |  8 ++------
 Superbuild/CMake/External_ossim.cmake       | 13 +++++--------
 Superbuild/CMake/External_pcre.cmake        |  9 +++------
 Superbuild/CMake/External_png.cmake         | 10 +++-------
 Superbuild/CMake/External_proj.cmake        |  9 +++------
 Superbuild/CMake/External_qt4.cmake         |  8 ++------
 Superbuild/CMake/External_sqlite.cmake      |  9 +++------
 Superbuild/CMake/External_swig.cmake        |  8 ++------
 Superbuild/CMake/External_tiff.cmake        |  7 ++-----
 Superbuild/CMake/External_tinyxml.cmake     |  8 ++------
 Superbuild/CMake/External_zlib.cmake        |  4 ++--
 25 files changed, 70 insertions(+), 149 deletions(-)

diff --git a/Superbuild/CMake/External_boost.cmake b/Superbuild/CMake/External_boost.cmake
index a39a228b5e..6c4381221d 100644
--- a/Superbuild/CMake/External_boost.cmake
+++ b/Superbuild/CMake/External_boost.cmake
@@ -1,16 +1,22 @@
-message(STATUS "Setup Boost ...")
-
 set(proj BOOST)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_BOOST  ON)
-
-option(USE_SYSTEM_BOOST "  Use a system build of Boost." ${DEFAULT_USE_SYSTEM_BOOST})
-mark_as_advanced(USE_SYSTEM_BOOST)
+message(STATUS "Setup Boost ...")
 
 if(USE_SYSTEM_BOOST)
+  # Required
+  find_package ( Boost
+    1.35.0
+    REQUIRED
+    )
+  
+  # Optional components
+  find_package ( Boost
+    1.35.0
+    COMPONENTS unit_test_framework
+    )
   message(STATUS "  Using Boost system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_curl.cmake b/Superbuild/CMake/External_curl.cmake
index f0d229e924..c74dbb44d0 100644
--- a/Superbuild/CMake/External_curl.cmake
+++ b/Superbuild/CMake/External_curl.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup cURL ...")
-
 set(proj CURL)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_CURL  ON)
-
-option(USE_SYSTEM_CURL "  Use a system build of cURL." ${DEFAULT_USE_SYSTEM_CURL})
-mark_as_advanced(USE_SYSTEM_CURL)
+message(STATUS "Setup cURL ...")
 
 if(USE_SYSTEM_CURL)
+  find_package ( CURL REQUIRED )
   message(STATUS "  Using cURL system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_expat.cmake b/Superbuild/CMake/External_expat.cmake
index 1aa9e2ad1e..399049cfe2 100644
--- a/Superbuild/CMake/External_expat.cmake
+++ b/Superbuild/CMake/External_expat.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup expat ...")
-
 set(proj EXPAT)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_EXPAT  OFF)
-
-option(USE_SYSTEM_EXPAT "  Use a system build of expat." ${DEFAULT_USE_SYSTEM_EXPAT})
-mark_as_advanced(USE_SYSTEM_EXPAT)
+message(STATUS "Setup expat ...")
 
 if(USE_SYSTEM_EXPAT)
+  find_package ( EXPAT REQUIRED )
   message(STATUS "  Using expat system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_fftw.cmake b/Superbuild/CMake/External_fftw.cmake
index 213c90b063..aa25cd92ff 100644
--- a/Superbuild/CMake/External_fftw.cmake
+++ b/Superbuild/CMake/External_fftw.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup FFTW ...")
-
 set(proj FFTW)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_FFTW  OFF)
-
-option(USE_SYSTEM_FFTW "  Use a system build of FFTW." ${DEFAULT_USE_SYSTEM_FFTW})
-mark_as_advanced(USE_SYSTEM_FFTW)
+message(STATUS "Setup FFTW ...")
 
 if(USE_SYSTEM_FFTW)
+  # TODO : use ITK's FindFFTW
+  find_package ( FFTW REQUIRED )
   message(STATUS "  Using FFTW system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_gdal.cmake b/Superbuild/CMake/External_gdal.cmake
index 7f93c8e17f..a15cdf0866 100644
--- a/Superbuild/CMake/External_gdal.cmake
+++ b/Superbuild/CMake/External_gdal.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup GDAL...")
-
 set(proj GDAL)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_GDAL  OFF)
-
-option(USE_SYSTEM_GDAL "  Use a system build of GDAL." ${DEFAULT_USE_SYSTEM_GDAL})
-mark_as_advanced(USE_SYSTEM_GDAL)
+message(STATUS "Setup GDAL...")
 
 if(USE_SYSTEM_GDAL)
+  find_package ( GDAL REQUIRED )
   message(STATUS "  Using GDAL system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_geos.cmake b/Superbuild/CMake/External_geos.cmake
index 4b5a2fb093..81f98efb3c 100644
--- a/Superbuild/CMake/External_geos.cmake
+++ b/Superbuild/CMake/External_geos.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup GEOS ...")
-
 set(proj GEOS)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_GEOS  OFF)
-
-option(USE_SYSTEM_GEOS "  Use a system build of GEOS." ${DEFAULT_USE_SYSTEM_GEOS})
-mark_as_advanced(USE_SYSTEM_GEOS)
+message(STATUS "Setup GEOS ...")
 
 if(USE_SYSTEM_GEOS)
+  # TODO : FindGEOS.cmake
+  #find_package ( GEOS REQUIRED )
   message(STATUS "  Using GEOS system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_geotiff.cmake b/Superbuild/CMake/External_geotiff.cmake
index 53be2ed394..3946f9f8fa 100644
--- a/Superbuild/CMake/External_geotiff.cmake
+++ b/Superbuild/CMake/External_geotiff.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup libgeotiff...")
-
 set(proj GEOTIFF)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_GEOTIFF  OFF)
-
-option(USE_SYSTEM_GEOTIFF "  Use a system build of libgeotiff." ${DEFAULT_USE_SYSTEM_GEOTIFF})
-mark_as_advanced(USE_SYSTEM_GEOTIFF)
+message(STATUS "Setup libgeotiff...")
 
 if(USE_SYSTEM_GEOTIFF)
+  find_package ( GeoTIFF REQUIRED )
   message(STATUS "  Using libgeotiff system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_itk.cmake b/Superbuild/CMake/External_itk.cmake
index 45d1179a58..a8e3cf7514 100644
--- a/Superbuild/CMake/External_itk.cmake
+++ b/Superbuild/CMake/External_itk.cmake
@@ -1,17 +1,12 @@
-message(STATUS "Setup ITK...")
-
 set(proj ITK)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-# Use an external version of ITK by default except on windows (ITK is not packaged in OSGeo4W)
-set(DEFAULT_USE_SYSTEM_ITK OFF)
-
-option(USE_SYSTEM_ITK "Use a system build of ITK." ${DEFAULT_USE_SYSTEM_ITK})
-mark_as_advanced(USE_SYSTEM_ITK)
+message(STATUS "Setup ITK...")
 
 if(USE_SYSTEM_ITK)
+  find_package ( ITK REQUIRED )
   message(STATUS "  Using ITK system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_jpeg.cmake b/Superbuild/CMake/External_jpeg.cmake
index 694096c4df..9db800f1fc 100644
--- a/Superbuild/CMake/External_jpeg.cmake
+++ b/Superbuild/CMake/External_jpeg.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup libjpeg...")
-
 set(proj JPEG)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_JPEG  OFF)
-
-option(USE_SYSTEM_JPEG "  Use a system build of libjpeg." ${DEFAULT_USE_SYSTEM_JPEG})
-mark_as_advanced(USE_SYSTEM_JPEG)
+message(STATUS "Setup libjpeg...")
 
 if(USE_SYSTEM_JPEG)
+  find_package ( JPEG REQUIRED )
   message(STATUS "  Using libjpeg system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_libkml.cmake b/Superbuild/CMake/External_libkml.cmake
index 9b36144a30..49ea3b6ce3 100644
--- a/Superbuild/CMake/External_libkml.cmake
+++ b/Superbuild/CMake/External_libkml.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup libKML ...")
-
 set(proj LIBKML)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_LIBKML  OFF)
-
-option(USE_SYSTEM_LIBKML "  Use a system build of libKML." ${DEFAULT_USE_SYSTEM_LIBKML})
-mark_as_advanced(USE_SYSTEM_LIBKML)
+message(STATUS "Setup libKML ...")
 
 if(USE_SYSTEM_LIBKML)
+  find_package ( LibKML REQUIRED )
   message(STATUS "  Using libKML system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_muparser.cmake b/Superbuild/CMake/External_muparser.cmake
index d4c86b4c33..921c471d18 100644
--- a/Superbuild/CMake/External_muparser.cmake
+++ b/Superbuild/CMake/External_muparser.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup muParser ...")
-
 set(proj MUPARSER)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_MUPARSER  OFF)
-
-option(USE_SYSTEM_MUPARSER "  Use a system build of muParser." ${DEFAULT_USE_SYSTEM_MUPARSER})
-mark_as_advanced(USE_SYSTEM_MUPARSER)
+message(STATUS "Setup muParser ...")
 
 if(USE_SYSTEM_MUPARSER)
+  find_package ( MUPARSER REQUIRED )
   message(STATUS "  Using muParser system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_muparserx.cmake b/Superbuild/CMake/External_muparserx.cmake
index 3332a9b12f..322eb554c1 100644
--- a/Superbuild/CMake/External_muparserx.cmake
+++ b/Superbuild/CMake/External_muparserx.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup muParserX ...")
-
 set(proj MUPARSERX)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_MUPARSERX  OFF)
-
-option(USE_SYSTEM_MUPARSERX "  Use a system build of muParserX." ${DEFAULT_USE_SYSTEM_MUPARSERX})
-mark_as_advanced(USE_SYSTEM_MUPARSERX)
+message(STATUS "Setup muParserX ...")
 
 if(USE_SYSTEM_MUPARSERX)
+  find_package ( MUPARSERX REQUIRED )
   message(STATUS "  Using muParserX system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_opencv.cmake b/Superbuild/CMake/External_opencv.cmake
index 38b302251a..c1b615733c 100644
--- a/Superbuild/CMake/External_opencv.cmake
+++ b/Superbuild/CMake/External_opencv.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup OpenCV...")
-
 set(proj OPENCV)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_OPENCV OFF)
-
-option(USE_SYSTEM_OPENCV "Use a system build of OpenCV." ${DEFAULT_USE_SYSTEM_OPENCV})
-mark_as_advanced(USE_SYSTEM_OPENCV)
+message(STATUS "Setup OpenCV...")
 
 if(USE_SYSTEM_OPENCV)
+  find_package ( OpenCV REQUIRED )
   message(STATUS "  Using OpenCV system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_openjpeg.cmake b/Superbuild/CMake/External_openjpeg.cmake
index a1ca58683a..b2d67434ce 100644
--- a/Superbuild/CMake/External_openjpeg.cmake
+++ b/Superbuild/CMake/External_openjpeg.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup OpenJpeg...")
-
 set(proj OPENJPEG)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_OPENJPEG  OFF)
-
-option(USE_SYSTEM_OPENJPEG "  Use a system build of OpenJpeg." ${DEFAULT_USE_SYSTEM_OPENJPEG})
-mark_as_advanced(USE_SYSTEM_OPENJPEG)
+message(STATUS "Setup OpenJpeg...")
 
 if(USE_SYSTEM_OPENJPEG)
+  # TODO : FindOpenJPEG.cmake
+  # find_package ( OpenJPEG REQUIRED )
   message(STATUS "  Using OpenJpeg system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_openthreads.cmake b/Superbuild/CMake/External_openthreads.cmake
index b10e510a04..56228c3f12 100644
--- a/Superbuild/CMake/External_openthreads.cmake
+++ b/Superbuild/CMake/External_openthreads.cmake
@@ -1,20 +1,16 @@
-message(STATUS "Setup OpenThreads ...")
-
 set(proj OPENTHREADS)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_OPENTHREADS  OFF)
-
-option(USE_SYSTEM_OPENTHREADS "  Use a system build of OpenThread." ${DEFAULT_USE_SYSTEM_OPENTHREADS})
-mark_as_advanced(USE_SYSTEM_OPENTHREADS)
+message(STATUS "Setup OpenThreads ...")
 
 if(MSVC)
 set(USE_SYSTEM_OPENTHREADS OFF)
 endif()
 
 if(USE_SYSTEM_OPENTHREADS)
+  find_package ( OpenThreads REQUIRED )
   message(STATUS "  Using OpenThread system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_ossim.cmake b/Superbuild/CMake/External_ossim.cmake
index 994b08c625..948c854292 100644
--- a/Superbuild/CMake/External_ossim.cmake
+++ b/Superbuild/CMake/External_ossim.cmake
@@ -1,23 +1,20 @@
-message(STATUS "Setup Ossim...")
-
 set(proj OSSIM)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_OSSIM  OFF)
+message(STATUS "Setup Ossim...")
 
 # OSGeo4W provides an "ossim" package : use it otherwise if it is installed and not used by OTB
 # we get conflicts (because OSGeo4W include dir is included for other dependencies
-if(WIN32)
-  set(DEFAULT_USE_SYSTEM_OSSIM  ON)
-endif()
-
-SETUP_SYSTEM_LIBRARY(PROJECT ${proj} DOC "  Use a system build of Ossim.")
+#if(WIN32)
+#  set(DEFAULT_USE_SYSTEM_OSSIM  ON)
+#endif()
 
 ADD_SYSTEM_LOCATION(PROJECT ${proj} VARIABLES ${proj}_LIBRARY ${proj}_INCLUDE_DIR)
 
 if(USE_SYSTEM_OSSIM)
+  find_package ( Ossim REQUIRED )
   message(STATUS "  Using OSSIM system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_pcre.cmake b/Superbuild/CMake/External_pcre.cmake
index c98d041afc..5cf70dac68 100644
--- a/Superbuild/CMake/External_pcre.cmake
+++ b/Superbuild/CMake/External_pcre.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup pcre...")
-
 set(proj PCRE)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_PCRE  ON)
-
-option(USE_SYSTEM_PCRE "  Use a system build of pcre." ${DEFAULT_USE_SYSTEM_PCRE})
-mark_as_advanced(USE_SYSTEM_PCRE)
+message(STATUS "Setup pcre...")
 
 if(USE_SYSTEM_PCRE)
+  # TODO : FindPCRE.cmake
+  # find_package ( PCRE REQUIRED )
   message(STATUS "  Using pcre system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_png.cmake b/Superbuild/CMake/External_png.cmake
index 2f7ff35655..0a25f5a340 100644
--- a/Superbuild/CMake/External_png.cmake
+++ b/Superbuild/CMake/External_png.cmake
@@ -1,17 +1,13 @@
-message(STATUS "Setup libpng...")
-
 set(proj PNG)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_PNG  ON)
-
-option(USE_SYSTEM_PNG "  Use a system build of libtiff." ${DEFAULT_USE_SYSTEM_PNG})
-mark_as_advanced(USE_SYSTEM_PNG)
+message(STATUS "Setup libpng...")
 
 if(USE_SYSTEM_PNG)
-  message(STATUS "  Using libtiff system version")
+  find_package ( PNG REQUIRED )
+  message(STATUS "  Using libpng system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
   
diff --git a/Superbuild/CMake/External_proj.cmake b/Superbuild/CMake/External_proj.cmake
index 338958e3d7..633d7ca5f6 100644
--- a/Superbuild/CMake/External_proj.cmake
+++ b/Superbuild/CMake/External_proj.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup Proj.4 ...")
-
 set(proj PROJ)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_PROJ  OFF)
-
-option(USE_SYSTEM_PROJ "  Use a system build of Proj.4." ${DEFAULT_USE_SYSTEM_PROJ})
-mark_as_advanced(USE_SYSTEM_PROJ)
+message(STATUS "Setup Proj.4 ...")
 
 if(USE_SYSTEM_PROJ)
+  # TODO : FindPROJ.cmake
+  #find_package ( PROJ REQUIRED )
   message(STATUS "  Using Proj4 system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_qt4.cmake b/Superbuild/CMake/External_qt4.cmake
index 253d0a7f3b..2813f5463d 100644
--- a/Superbuild/CMake/External_qt4.cmake
+++ b/Superbuild/CMake/External_qt4.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup Qt4 ...")
-
 set(proj QT4)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_QT4  ON)
-
-option(USE_SYSTEM_QT4 "  Use a system build of Qt4." ${DEFAULT_USE_SYSTEM_QT4})
-mark_as_advanced(USE_SYSTEM_QT4)
+message(STATUS "Setup Qt4 ...")
 
 if(USE_SYSTEM_QT4)
+  find_package ( QT4 REQUIRED )
   message(STATUS "  Using Qt4 system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_sqlite.cmake b/Superbuild/CMake/External_sqlite.cmake
index 19f3dfc890..aef7505285 100644
--- a/Superbuild/CMake/External_sqlite.cmake
+++ b/Superbuild/CMake/External_sqlite.cmake
@@ -1,16 +1,13 @@
-message(STATUS "Setup SQLite...")
-
 set(proj SQLITE)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_SQLITE  OFF)
-
-option(USE_SYSTEM_SQLITE "  Use a system build of SQLite." ${DEFAULT_USE_SYSTEM_SQLITE})
-mark_as_advanced(USE_SYSTEM_SQLITE)
+message(STATUS "Setup SQLite...")
 
 if(USE_SYSTEM_SQLITE)
+  # TODO
+  #find_package ( SQLite REQUIRED )
   message(STATUS "  Using SQLite system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_swig.cmake b/Superbuild/CMake/External_swig.cmake
index 5020828b2f..dc43847d8e 100644
--- a/Superbuild/CMake/External_swig.cmake
+++ b/Superbuild/CMake/External_swig.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup swig...")
-
 set(proj SWIG)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_SWIG  ON)
-
-option(USE_SYSTEM_SWIG "  Use a system build of swig." ${DEFAULT_USE_SYSTEM_SWIG})
-mark_as_advanced(USE_SYSTEM_SWIG)
+message(STATUS "Setup swig...")
 
 if(USE_SYSTEM_SWIG)
+  find_package ( SWIG REQUIRED )
   message(STATUS "  Using swig system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_tiff.cmake b/Superbuild/CMake/External_tiff.cmake
index ee259d6328..013371582b 100644
--- a/Superbuild/CMake/External_tiff.cmake
+++ b/Superbuild/CMake/External_tiff.cmake
@@ -1,19 +1,16 @@
-message(STATUS "Setup libtiff...")
-
 set(proj TIFF)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_TIFF  OFF)
-
-SETUP_SYSTEM_LIBRARY(PROJECT ${proj} DOC "  Use a system build of libtiff.")
+message(STATUS "Setup libtiff...")
 
 ADD_SYSTEM_LOCATION(PROJECT ${proj} VARIABLES ${proj}_LIBRARY ${proj}_INCLUDE_DIR)
 
 ADD_SYSTEM_PREFIX(PROJECT ${proj})
 
 if(USE_SYSTEM_TIFF)
+  find_package ( TIFF REQUIRED )
   message(STATUS "  Using libtiff system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_tinyxml.cmake b/Superbuild/CMake/External_tinyxml.cmake
index 7e5ac5775e..f28fbf6cf6 100644
--- a/Superbuild/CMake/External_tinyxml.cmake
+++ b/Superbuild/CMake/External_tinyxml.cmake
@@ -1,16 +1,12 @@
-message(STATUS "Setup TinyXML ...")
-
 set(proj TINYXML)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
-set(DEFAULT_USE_SYSTEM_TINYXML  OFF)
-
-option(USE_SYSTEM_TINYXML "  Use a system build of TinyXML." ${DEFAULT_USE_SYSTEM_TINYXML})
-mark_as_advanced(USE_SYSTEM_TINYXML)
+message(STATUS "Setup TinyXML ...")
 
 if(USE_SYSTEM_TINYXML)
+  find_package ( TinyXML REQUIRED )
   message(STATUS "  Using TinyXML system version")
 else()
   SETUP_SUPERBUILD(PROJECT ${proj})
diff --git a/Superbuild/CMake/External_zlib.cmake b/Superbuild/CMake/External_zlib.cmake
index 3bc40c6bd9..53681c47bc 100644
--- a/Superbuild/CMake/External_zlib.cmake
+++ b/Superbuild/CMake/External_zlib.cmake
@@ -1,10 +1,10 @@
-message(STATUS "Setup Zlib ...")
-
 set(proj ZLIB)
 
 if(NOT __EXTERNAL_${proj}__)
 set(__EXTERNAL_${proj}__ 1)
 
+message(STATUS "Setup Zlib ...")
+
 ADD_SYSTEM_PREFIX(PROJECT ${proj} CMAKE_ALIAS ZLIB_ROOT)
 
 if(USE_SYSTEM_ZLIB)
-- 
GitLab