Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40391

a CMP0218 warning with cmake 4.4

    XMLWordPrintable

Details

    • Notable changes

    Description

      When compiling with cmake 4.4 I get the following warning:

      [cmake] CMake Warning (policy) at cmake/plugin.cmake:342 (IF):
      [cmake]   Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
      [cmake]   CMAKE_ERROR_DEPRECATED variables are ignored.  Run "cmake --help-policy
      [cmake]   CMP0218" for policy details.  Use the cmake_policy command to set the
      [cmake]   policy and suppress this warning.
      [cmake] Call Stack (most recent call first):
      [cmake]   CMakeLists.txt:490 (CONFIGURE_PLUGINS)
      [cmake] This warning is for project developers.  Use -Wno-author or -Wno-policy to
      [cmake] suppress it.
      [cmake] 
      [cmake] CMake Warning (policy) at cmake/plugin.cmake:342 (IF):
      [cmake]   Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
      [cmake]   CMAKE_ERROR_DEPRECATED variables are ignored.  Run "cmake --help-policy
      [cmake]   CMP0218" for policy details.  Use the cmake_policy command to set the
      [cmake]   policy and suppress this warning.
      [cmake] Call Stack (most recent call first):
      [cmake]   CMakeLists.txt:490 (CONFIGURE_PLUGINS)
      [cmake] This warning is for project developers.  Use -Wno-author or -Wno-policy to
      [cmake] suppress it.
      [cmake] 
      [cmake] -- Configuring done (1.8s)
      [cmake] -- Generating done (0.9s)
      [cmake] -- Build files have been written to: /Users/gkodinov/dev/server-10.11/bld
      

      This is about the following fragment in cmake/plugin.cmake:

        GET_CMAKE_PROPERTY(ALL_VARS VARIABLES)
        FOREACH (V ${ALL_VARS})
          IF (V MATCHES "^PLUGIN_" AND ${V} MATCHES "YES")
            STRING(SUBSTRING ${V} 7 -1 plugin)
            STRING(TOLOWER ${plugin} target)
            IF (NOT TARGET ${target})
              MESSAGE(FATAL_ERROR "Plugin ${plugin} cannot be built")
            ENDIF()
          ENDIF()
        ENDFOREACH()
      

      It looks like cmake always evaluates all conditions in a IF() statement even if the LHS of an AND is FALSE. So you get a warning as a result because of the CMAKE_WARN_DEPRECATED variable.

      The fix is to break the IF():

        GET_CMAKE_PROPERTY(ALL_VARS VARIABLES)
        FOREACH (V ${ALL_VARS})
          IF (V MATCHES "^PLUGIN_")
            IF (${V} MATCHES "YES")
              STRING(SUBSTRING ${V} 7 -1 plugin)
              STRING(TOLOWER ${plugin} target)
              IF (NOT TARGET ${target})
                MESSAGE(FATAL_ERROR "Plugin ${plugin} cannot be built")
              ENDIF()
            ENDIF()
          ENDIF()
        ENDFOREACH()
      

      Attachments

        Activity

          People

            gkodinov Georgi Kodinov
            gkodinov Georgi Kodinov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.