Is this an intended change to cmake behavior in cmake 3.12?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is this an intended change to cmake behavior in cmake 3.12?

Buster, James

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 runcmake .” 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.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Is this an intended change to cmake behavior in cmake 3.12?

Brad King
On 07/20/2018 11:48 AM, Buster, James wrote:
> 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.

Thanks.  I opened an issue for it:

  https://gitlab.kitware.com/cmake/cmake/issues/18202

Please see that issue for further discussion.

> 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.

If no project() command appears anywhere in the top-level CMakeLists.txt
file then one is injected on line zero.  That is the one that causes
the warning.  When it is present in the inline macro then no injection
is done.  It's strange but that's how things evolved.

-Brad
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Is this an intended change to cmake behavior in cmake 3.12?

Brad King
On 07/24/2018 10:28 AM, Brad King wrote:
> If no project() command appears anywhere in the top-level CMakeLists.txt
> file then one is injected on line zero.

FWIW, see this note in the project command docs:

  https://cmake.org/cmake/help/v3.12/command/project.html

"The top-level CMakeLists.txt file for a project must contain a literal,
 direct call to the project() command..."

While we can look into the issue, please also update your project
to follow this recommendation.

-Brad
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake