--- libmysql/CMakeLists.txt.orig	2024-07-12 19:15:25 UTC
+++ libmysql/CMakeLists.txt
@@ -205,6 +205,11 @@ ENDIF()
   )
 ENDIF()
 
+INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
+IF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+  ADD_COMPILE_FLAGS(${CLIENT_SOURCES} COMPILE_FLAGS "-fPIC")
+ENDIF()
+
 #
 # Include protocol tracing infrastructure and the test
 # trace plugin if enabled by build options.
@@ -281,8 +286,15 @@ ENDIF()
   LIST(APPEND LIBS_TO_MERGE auth_win_client)
 ENDIF()
 
-# LDAP authentication SASL client plug-in
-ADD_SUBDIRECTORY(authentication_ldap)
+IF(WITHOUT_CLIENTLIBS)
+  # Merge several convenience libraries into one big mysqlclient
+  MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERGE}
+  COMPONENT Development
+  SKIP_INSTALL)
+ELSE(WITHOUT_CLIENTLIBS)
+  # LDAP authentication SASL client plugin
+  MESSAGE(STATUS "Creating LDAP authentication SASL client library.")
+  ADD_SUBDIRECTORY(authentication_ldap)
 
 # FIDO authentication client plugin
 ADD_SUBDIRECTORY(authentication_fido)
@@ -298,6 +310,7 @@ MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERG
   COMPONENT Development
   LINK_LIBRARIES ${LIBS_TO_LINK}
   )
+ENDIF(WITHOUT_CLIENTLIBS)
 
 # Visual Studio users need debug  static library for debug projects
 IF(MSVC)
@@ -344,17 +357,27 @@ ENDIF()
 
 # Merge several convenience libraries into one big mysqlclient
 # and link them together into shared library.
+IF(WITHOUT_CLIENTLIBS)
 MERGE_LIBRARIES_SHARED(libmysql ${LIBS_TO_MERGE}
   EXPORTS
   ${CLIENT_API_FUNCTIONS}
   ${CLIENT_API_FUNCTIONS_UNDOCUMENTED}
   ${CLIENT_API_NONBLOCKING_FUNCTIONS}
   COMPONENT SharedLibraries
+  SKIP_INSTALL )
+ELSE(WITHOUT_CLIENTLIBS)
+MERGE_LIBRARIES_SHARED(libmysql ${LIBS_TO_MERGE}
+  EXPORTS
+  ${CLIENT_API_FUNCTIONS}
+  ${CLIENT_API_FUNCTIONS_UNDOCUMENTED}
+  ${CLIENT_API_NONBLOCKING_FUNCTIONS}
+  COMPONENT SharedLibraries
   LINK_LIBRARIES ${LIBS_TO_LINK}
   ${UNIX_OUTPUT_NAME}
   ${UNIX_SOVERSION}
   ${UNIX_VERSION}
   )
+ENDIF(WITHOUT_CLIENTLIBS)
 
 # Downgrade warning for strncat in my_crypt_genhash.
 IF((WITH_LTO OR CMAKE_COMPILER_FLAG_WITH_LTO) AND MY_COMPILER_IS_GNU)
