Description:
CMake 3.0 reports many warnings in compilation as follows:
$ cmake .
...
CMake Warning (dev) at cmake/libevent.cmake:22 (GET_TARGET_PROPERTY):
Policy CMP0045 is not set: Error on non-existent target in
get_target_property. Run "cmake --help-policy CMP0045" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
get_target_property() called with non-existent target "libevent".
Call Stack (most recent call first):
cmake/libevent.cmake:45 (MYSQL_USE_BUNDLED_LIBEVENT)
CMakeLists.txt:419 (MYSQL_CHECK_LIBEVENT)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at cmake/install_macros.cmake:225 (GET_TARGET_PROPERTY):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "myisam_ftdump". Use
the target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
Call Stack (most recent call first):
cmake/mysql_add_executable.cmake:54 (MYSQL_INSTALL_TARGETS)
storage/myisam/CMakeLists.txt:37 (MYSQL_ADD_EXECUTABLE)
This warning is for project developers. Use -Wno-dev to suppress it.
...
CMake 3.0 reports these warnings because the OLD behaviors are implicitly used.
http://www.cmake.org/cmake/help/v3.0/policy/CMP0026.html
http://www.cmake.org/cmake/help/v3.0/policy/CMP0045.html
The above CMake documents say "This policy was introduced in CMake version 3.0. CMake version 3.0.0 warns when the policy is not set and uses OLD behavior. Use the cmake_policy command to set it to OLD or NEW explicitly."
How to repeat:
CMake 3.0 reports many warnings in compilation.
Please see the description.
Suggested fix:
The latest CMakeLists.txt (MySQL 5.6.19) already uses CMAKE_POLICY as follows:
# We use PROPERTIES LINK_INTERFACE_LIBRARIES. See cmake --help-policy CMP0022
IF(CMAKE_VERSION VERSION_EQUAL "2.8.12" OR
CMAKE_VERSION VERSION_GREATER "2.8.12")
CMAKE_POLICY(SET CMP0022 OLD)
ENDIF()
Similarly, you can suppress the new warnings with CMAKE_POLICY.
Please note that there are two ways to check CMake policy availability.
1. Use the CMake version
IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
CMAKE_VERSION VERSION_GREATER "3.0.0")
CMAKE_POLICY(SET CMP0026 OLD)
CMAKE_POLICY(SET CMP0045 OLD)
ENDIF()
2. Use POLICY
IF(POLICY CMP0026)
CMAKE_POLICY(SET CMP0026 OLD)
ENDIF()
IF(POLICY CMP0045)
CMAKE_POLICY(SET CMP0045 OLD)
ENDIF()
Both worked well on my environment (Ubuntu 14.04).