[CMake] CMake Version Specific Code and Testing

Robert Maynard robert.maynard at kitware.com
Tue Apr 3 16:13:08 EDT 2018


> if I (accidentally, or through ignorance) write code that would only work in CMake 3.x but not in 2.8.12, will the build fail or should I make sure to install 2.8.12 and test using that? ....  if I ended up using an entirely new command that did not exist at the time of 2.8.12, but does exist in 3.10 of my installed CMake, should the build fail or succeed?

The in both cases if you have CMake 3.X installed the
configure/generate of your project will succeed. You will need to
install CMake 2.8.12 and test with that.

> Policy logic

You are correct about policy guards allowing older versions of CMake
to safely ignore policies from new releases, while people running
newer versions of CMake can leverage those ( generally the performance
related policies ).

On Tue, Apr 3, 2018 at 12:38 PM, Stephen McDowell <sjm324 at cornell.edu> wrote:
> Hello,
>
> Suppose I have a cmake_minimum_required(VERSION 2.8.12) project I would like
> to contribute to.
>
> So when I am testing code for a v2.8.12 project, but my installed CMake
> version is say 3.10, if I (accidentally, or through ignorance) write code
> that would only work in CMake 3.x but not in 2.8.12, will the build fail or
> should I make sure to install 2.8.12 and test using that?
>
> For example, my understanding is that for things like policies, I can do
>
> if (POLICY CMP<NNNN>)
>   cmake_policy(SET CMP<NNNN> NEW)
> endif()
>
> and this will mean that an older version of CMake running this code that
> does not know about policy NNNN will still work.  But if I ended up using an
> entirely new command that did not exist at the time of 2.8.12, but does
> exist in 3.10 of my installed CMake, should the build fail or succeed?
>
> Thanks for any guidance, I’m sorry if this question doesn’t make any sense…
>
> -Stephen
>
>
> --
>
> 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
>


More information about the CMake mailing list