Use the METIS library provided by the user

METIS::METIS took its location only from the configuration specific
libraries found by the module. Providing METIS_LIBRARY directly either
left the target without a location, failing the generation, or was
silently ignored in favor of a library found in the system paths.

Derive the target location from METIS_LIBRARY and only use configuration
specific locations if it refers to both a debug and a release library.

Change-Id: I32a8516d0852430d3770cd9ef685c21bf5d6d9cc
diff --git a/cmake/FindMETIS.cmake b/cmake/FindMETIS.cmake
index 857e6ad..12fa669 100644
--- a/cmake/FindMETIS.cmake
+++ b/cmake/FindMETIS.cmake
@@ -92,19 +92,20 @@
     ${METIS_INCLUDE_DIR})
 endif (METIS_INCLUDE_DIR)
 
-if (METIS_LIBRARY_RELEASE)
+# METIS_LIBRARY takes precedence since it can also be provided by the user.
+# Configuration specific locations are used only if it refers to both the
+# debug and the release library.
+if (METIS_LIBRARY MATCHES "^(debug|optimized);")
   set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_RELEASE
     ${METIS_LIBRARY_RELEASE})
-  set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
-    RELEASE)
-endif (METIS_LIBRARY_RELEASE)
-
-if (METIS_LIBRARY_DEBUG)
   set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_DEBUG
     ${METIS_LIBRARY_DEBUG})
   set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
-    DEBUG)
-endif (METIS_LIBRARY_DEBUG)
+    RELEASE DEBUG)
+elseif (METIS_LIBRARY)
+  set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION
+    ${METIS_LIBRARY})
+endif (METIS_LIBRARY MATCHES "^(debug|optimized);")
 
 find_package_handle_standard_args (METIS REQUIRED_VARS
   METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)