How to fix cmake_minimum_required() deprecation warning?

Hi,

Today when I recompiled one of my C++ projects using CMake I got the following deprecation warning:

% cmake .. -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 2.8)
project(libpopcnt C CXX)
...

So I could fix this issue by simply increasing the minimum version (here 2.8) to something bigger. But then in a few years, the same issue will reappear when the new minimum version will be deprecated.

Is there a workaround for this issue, where I don’t need to update my code every few years to fix this issue? I know that my project does not compile with CMake 2.7, but I expect my project to compile with CMake >= 2.8.

Thanks for your help.