Skip to content

FindMySQL.cmake: Remove MySQL_VERSION

Thomas Ives requested to merge remove-mysql-version into main

Currently, we use a try_run call to determine the version of MySQL we are linking against by printing the string returned by mysql_get_client_info().

Common CMake advice is that try_run should generally be avoided because it causes issues when cross-compiling, see #66 (closed). The standard alternative to a try_run for finding version information is to use regex's to extract the information from a header file, as is done in FindTango.cmake. However, this is not trivial in our case because:

1. MariaDB provides architecture specific version header files,
   e.g. mariadb_version-x86_64.h, making it difficult to locate the
   relevant file.
2. The header files contain various, seemingly unrelated, version
   defines and it is unclear which of these we should be using.

This version information is not actually used as we do not pass a VERSION requirement when we call find_package(MySQL). Moreover, myqsl_get_client_info() is probably not a useful way of obtaining version information because it does not seem to be consistent between different MySQL projects. The MariaDB package on Fedora 37 seems to return the value of the MARIADB_PACKAGE_VERSION (e.g. 3.2.7) whereas for MySQL 5.7 on Windows we get the value of MYSQL_SERVER_VERSION (e.g. 5.7.40). As such, if we needed the version information in the future we would probably need to change how we are retrieving it in some way anyway.

Rather than trying to fix how we find MySQL_VERSION when we do not know exactly what we are looking for, let's just remove it as it causes headaches when we cross compile. If we need to check the version of MySQL at some point in the future we can add something back in with a real use case to guide us.

Closes #66 (closed).

Merge request reports