Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-89866

FindMySQL.cmake doesn't follow CMake conventions for variable naming

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.1.0
    • 6.0.0
    • Build System: CMake
    • None
    • e74fd6897bbb511fe365e8189e04c0cdc4d51655 (qt/qtbase/dev)

    Description

      The FindMySQL module in qtbase/cmake contains the following code:

      find_path(MySQL_INCLUDE_DIRS
                NAMES mysql.h
                HINTS ${PC_MySQL_INCLUDEDIR}
                PATH_SUFFIXES mysql)
      
      find_library(MySQL_LIBRARIES
                   NAMES mysqlclient
                   HINTS ${PC_MySQL_LIBDIR}
      )
      
      include(FindPackageHandleStandardArgs)
      find_package_handle_standard_args(MySQL DEFAULT_MSG MySQL_LIBRARIES MySQL_INCLUDE_DIRS)
      

      This is not following the CMake conventions, as documented here:

      https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names

      Specifically, the find_path() and find_library() calls should use the singular variable names MySQL_INCLUDE_DIR and MySQL_LIBRARY respectively. These commands are finding a single entity. The plural version of these variable names should not be stored in the cache and should be formed by populating them from the singular versions. The singular variable names should also be given to find_package_handle_standard_args().

      Note that there are also configure scripts and documentation that are using the plural forms too and would need to be updated as well. I don't know the history of this module, if it pre-dates Qt6 it might already be too late to change this. If necessary, we could probably add some logic to fall back to the plural forms if the singular forms are not populated but the plural forms are in the cache.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            semlanik Alexey Edelev
            crscott Craig Scott
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes