Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 rock-master-20.06-base-cmake (0.20200514-1~bionic) unstable; urgency=low
 .
   * Package automatically built using 'apaka'
   * repository: github:/rock-core/base-cmake.git
   * branch: refs/heads/master
   * commit: 7b0463f9c71cffeb4b4c2413b4c9a60f19893177
   * tag:
Author: Rock Packaging Daemon (based on apaka) <rock-dev@dfki.de>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-09-04

--- rock-master-20.06-base-cmake-0.20200514.orig/modules/FindGem.cmake
+++ rock-master-20.06-base-cmake-0.20200514/modules/FindGem.cmake
@@ -62,8 +62,26 @@ endif()
 foreach(Gem_NAME ${Gem_FIND_COMPONENTS})
     set(GEM_${Gem_NAME}_FOUND FALSE)
     list(APPEND components_found_vars GEM_${Gem_NAME}_FOUND)
-    # If the gem is installed as a gem
-    if(NOT GEM_OS_PKG)
+
+    pkg_check_modules(GEM_PKG QUIET ${Gem_NAME})
+    set(GEM_${Gem_NAME}_FOUND ${GEM_PKG_FOUND})
+
+    if(GEM_PKG_FOUND)
+        set(GEM_INCLUDE_DIRS ${GEM_PKG_INCLUDE_DIRS})
+        set(GEM_LIBRARIES ${GEM_PKG_LIBRARIES} ${GEM_PKG_STATIC_LIBRARIES})
+        list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS} ${GEM_PKG_STATIC_LDFLAGS})
+        list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS_OTHER} ${GEM_PKG_STATIC_LDFLAGS_OTHER})
+
+        if(GEM_DEBUG)
+            message(STATUS "GEM_OS_PKG is defined")
+            message(STATUS "GEM_INCLUDE_DIRS ${GEM_INCLUDE_DIRS}")
+            message(STATUS "GEM_STATIC_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
+            message(STATUS "GEM_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
+            message(STATUS "GEM_STATIC_LIBRARIES ${GEM_PKG_STATIC_LIBRARIES}")
+            message(STATUS "GEM_LIBRARIES ${GEM_LIBRARIES}")
+        endif()
+    else(GEM_PKG_FOUND)
+        # Check if the gem is installed as a gem
         # Use `gem content <gem-name>` to extract current information about installed gems
         # Store the information into ${GEM_LOCAL_INFO}
         EXECUTE_PROCESS(COMMAND ${GEM_EXECUTABLE} content ${Gem_NAME}
@@ -119,24 +137,6 @@ foreach(Gem_NAME ${Gem_FIND_COMPONENTS})
                 endforeach()
             endforeach()
             set(GEM_${Gem_NAME}_FOUND TRUE)
-        else()
-            set(GEM_${Gem_NAME}_FOUND FALSE)
-        endif()
-    else(NOT GEM_OS_PKG)
-        pkg_check_modules(GEM_PKG ${Gem_NAME})
-        set(GEM_${Gem_NAME}_FOUND ${GEM_PKG_FOUND})
-        set(GEM_INCLUDE_DIRS ${GEM_PKG_INCLUDE_DIRS})
-        set(GEM_LIBRARIES ${GEM_PKG_LIBRARIES} ${GEM_PKG_STATIC_LIBRARIES})
-        list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS} ${GEM_PKG_STATIC_LDFLAGS})
-        list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS_OTHER} ${GEM_PKG_STATIC_LDFLAGS_OTHER})
-
-        if(GEM_DEBUG)
-            message(STATUS "GEM_OS_PKG is defined")
-            message(STATUS "GEM_INCLUDE_DIRS ${GEM_INCLUDE_DIRS}")
-            message(STATUS "GEM_STATIC_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
-            message(STATUS "GEM_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
-            message(STATUS "GEM_STATIC_LIBRARIES ${GEM_PKG_STATIC_LIBRARIES}")
-            message(STATUS "GEM_LIBRARIES ${GEM_LIBRARIES}")
         endif()
     endif()
 endforeach()
