--- CMakeLists.txt.orig	2021-09-28 11:46:34 UTC
+++ CMakeLists.txt
@@ -1647,7 +1647,7 @@ IF(LINUX AND KNOWN_CUSTOM_LIBRARIES)
 ENDIF()
 
 IF(WITH_AUTHENTICATION_LDAP)
-  IF(LINUX AND KNOWN_CUSTOM_LIBRARIES)
+  IF(LINUX OR FREEBSD AND KNOWN_CUSTOM_LIBRARIES)
     # LDAP / SASL / KERBEROS / SSL must all be "system" or "custom", not a mix.
     IF(WITH_LDAP STREQUAL "system" OR
         WITH_SASL STREQUAL "system" OR
@@ -1696,10 +1696,10 @@ IF(WITH_AUTHENTICATION_KERBEROS)
   ENDIF()
 ENDIF()
 
-# Add system/bundled editline.
-MYSQL_CHECK_EDITLINE()
 # Add libevent
-MYSQL_CHECK_LIBEVENT()
+IF(NOT WITHOUT_SERVER)
+  MYSQL_CHECK_LIBEVENT()
+ENDIF()
 # Add lz4 library
 MYSQL_CHECK_LZ4()
 # Add icu library
@@ -1869,7 +1869,9 @@ OPTION(WITH_HYPERGRAPH_OPTIMIZER
   ${WITH_HYPERGRAPH_OPTIMIZER_DEFAULT}
   )
 
-ADD_SUBDIRECTORY(include)
+IF(NOT WITHOUT_CLIENTLIBS)
+  ADD_SUBDIRECTORY(include)
+ENDIF(NOT WITHOUT_CLIENTLIBS)
 ADD_SUBDIRECTORY(strings)
 ADD_SUBDIRECTORY(vio)
 ADD_SUBDIRECTORY(mysys)
@@ -1913,12 +1915,17 @@ IF(WITH_UNIT_TESTS)
   ADD_SUBDIRECTORY(unittest/mytap/t)
 ENDIF()
 
-ADD_SUBDIRECTORY(client)
+IF(NOT WITHOUT_TOOLS)
+  # Add system/bundled editline
+  MYSQL_CHECK_EDITLINE()
+  ADD_SUBDIRECTORY(client)
+ENDIF(NOT WITHOUT_TOOLS)
+
 ADD_SUBDIRECTORY(utilities)
-ADD_SUBDIRECTORY(share)
 ADD_SUBDIRECTORY(libservices)
 
 IF(NOT WITHOUT_SERVER)
+  ADD_SUBDIRECTORY(share)
   ADD_SUBDIRECTORY(testclients)
   ADD_SUBDIRECTORY(sql)
 ENDIF()
@@ -1971,11 +1978,11 @@ ENDIF()
 # scripts/mysql_config depends on client and server targets loaded above.
 # It is referenced by some of the directories below, so we insert it here.
 ADD_SUBDIRECTORY(scripts)
+ADD_SUBDIRECTORY(support-files)
 
 IF(NOT WITHOUT_SERVER)
   ADD_SUBDIRECTORY(mysql-test)
   ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
-  ADD_SUBDIRECTORY(support-files)
   IF(WITH_INTERNAL)
     ADD_SUBDIRECTORY(internal)
   ENDIF()
@@ -2084,6 +2091,7 @@ IF(PACK_SEPARATE_COMPONENTS)
   SET(CPACK_COMPONENTS_GROUPING IGNORE)
 ENDIF()
 
+IF(FALSE)
 IF(UNIX)
   INSTALL(FILES
     Docs/mysql.info
@@ -2118,6 +2126,7 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM")
     PATTERN "sp-imp-spec.txt" EXCLUDE
     PATTERN "README.build" EXCLUDE
   )
+ENDIF()
 ENDIF()
 
 # Now that we're done with all ADD_SUBDIRECTORY and thus all feature tests,
