[CMake] Is this an intended change to cmake behavior in cmake 3.12?

Buster, James James.Buster at transunion.com
Fri Jul 20 11:48:01 EDT 2018


CMakeLists.txt:
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

include(foo)

#macro(test_project2 name target)
#    project(${name} ${ARGN})
#endmacro(test_project2)

test_project(runtime TRUE VERSION 1.0)

foo.cmake:
macro(test_project name target)
    project(${name} ${ARGN})
endmacro(test_project)

The test:
Save the two files then run "cmake ." on this CMakeLists.txt twice in succession.

Using cmake 3.11 or earlier: no problems
Using cmake 3.12: the second "cmake ." issues the following warning:
CMake Warning (dev) in CMakeLists.txt:
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR

That by itself is weird, but it gets better. See the "test_project2" macro in CMakeLists.txt? Simply uncomment it.
Even though it isn't called, uncommenting that macro causes the "Policy CMP0048" warning to disappear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180720/2e1725be/attachment-0001.html>


More information about the CMake mailing list