From 65647861f43e22c83f5be69c26b64b60461c8e86 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Mon, 25 Jun 2018 16:30:45 +0200
Subject: [PATCH] Fix some issues with lib order

---
 modules/GenPkgConfig.cmake | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/GenPkgConfig.cmake b/modules/GenPkgConfig.cmake
index 9c75c19..090331b 100644
--- a/modules/GenPkgConfig.cmake
+++ b/modules/GenPkgConfig.cmake
@@ -88,6 +88,13 @@ endmacro(gpc_convert_incstyle_to_pkgconfig)
 #
 ###
 macro(gpc_convert_libstyle_to_pkgconfig _liblist)
+
+  # Start by removing duplicates
+  list(REVERSE ${_liblist})
+  list(REMOVE_DUPLICATES ${_liblist})
+  list(REVERSE ${_liblist})
+
+  # Convert to pkg-config file format
   set(${_liblist}_CPY "${${_liblist}}")
   set(${_liblist} "")
   foreach(_dep ${${_liblist}_CPY})
@@ -121,16 +128,10 @@ macro(gpc_clean_lib_list _package)
     string(REPLACE ";" " " ${_package}_PKGCONFIG_INCS "${${_package}_PKGCONFIG_INCS}")
   endif()
   if ( ${_package}_PKGCONFIG_LIBS )
-    list(REVERSE ${_package}_PKGCONFIG_LIBS)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS)
-    list(REVERSE ${_package}_PKGCONFIG_LIBS)
     gpc_convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS)
     string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS "${${_package}_PKGCONFIG_LIBS}")
   endif()
   if ( ${_package}_PKGCONFIG_LIBS_PRIVATE )
-    list(REVERSE ${_package}_PKGCONFIG_LIBS_PRIVATE)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS_PRIVATE)
-    list(REVERSE ${_package}_PKGCONFIG_LIBS_PRIVATE)
     gpc_convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS_PRIVATE)
     string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS_PRIVATE "${${_package}_PKGCONFIG_LIBS_PRIVATE}")
   endif()
-- 
GitLab