--- scripts/CMakeLists.txt.orig	2019-09-20 08:30:51 UTC
+++ scripts/CMakeLists.txt
@@ -330,7 +330,7 @@ MACRO(EXTRACT_LINK_LIBRARIES target var)
     LIST(REMOVE_DUPLICATES ${target}_LIB_DEPENDS)
     FOREACH(lib ${${target}_LIB_DEPENDS})
       # Filter out "general", it is not a library, just CMake hint
-      IF(NOT lib STREQUAL "general" AND NOT ${var}  MATCHES "-l${lib} ")
+      IF(NOT lib STREQUAL "general" AND NOT ${var}  MATCHES "-l${lib} " AND NOT lib STREQUAL "imported_openssl" AND NOT lib STREQUAL "imported_crypto")
         IF (lib MATCHES "^\\-l")
           SET(${var} "${${var}} ${lib} ")
         ELSEIF (lib MATCHES "^\\-L")
@@ -340,6 +340,8 @@ MACRO(EXTRACT_LINK_LIBRARIES target var)
           GET_FILENAME_COMPONENT(lib "${lib}" NAME_WE)
           STRING(REGEX REPLACE "^lib" "" lib "${lib}")
           SET(${var} "${${var}}-l${lib} " )
+        ELSEIF(lib STREQUAL "-pthread")
+          SET(${var} "${${var}}-pthread " )
         ELSE()
           SET(${var} "${${var}}-l${lib} " )
         ENDIF()
@@ -414,7 +416,7 @@ ELSE()
     ${CMAKE_CURRENT_BINARY_DIR}/${PKGCONFIG_FILE}
     ESCAPE_QUOTES @ONLY)
 
-  IF(INSTALL_PKGCONFIGDIR)
+  IF(INSTALL_PKGCONFIGDIR AND NOT WITHOUT_CLIENTLIBS)
     MESSAGE(STATUS "INSTALL ${PKGCONFIG_FILE} ${INSTALL_PKGCONFIGDIR}")
     INSTALL(FILES
       ${CMAKE_CURRENT_BINARY_DIR}/${PKGCONFIG_FILE}
@@ -427,23 +429,28 @@ ELSE()
   # mysqld_safe used in mtr even for systemd platforms
   IF(WITH_SYSTEMD)
     SET(BIN_SCRIPTS
-      mysql_config
       mysqldumpslow
       mysqld_safe
       )
   ELSE()
     SET(BIN_SCRIPTS
-      mysql_config
       mysqldumpslow
       mysqld_multi
       mysqld_safe
       )
   ENDIF()
 
+  IF(NOT WITHOUT_CLIENTLIBS)
+    SET(BIN_SCRIPTS
+      ${BIN_SCRIPTS}
+      mysql_config
+    )
+  ENDIF(NOT WITHOUT_CLIENTLIBS)
+
   FOREACH(file ${BIN_SCRIPTS})
     IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
       CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
-        ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY
+        ${CMAKE_CURRENT_BINARY_DIR}/${file} @ONLY
         )
     ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.pl.in)
       CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.pl.in
