user8044236
user8044236

Reputation:

How to automatically choose minimal cmake version based on used features?

For example I want to specify c++ standard in CMakeLists.txt:

set_property(TARGET tgt PROPERTY CXX_STANDARD 98)

But this is available only since cmake 3.1.3. Unfortunately I am still able to write at the first line of CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

How can I be sure that I specify correct requirements (3.1.3 instead of 2.8)?

Upvotes: 9

Views: 492

Answers (1)

usr1234567
usr1234567

Reputation: 23294

The command cmake_minimum_required is not meant to check whether your code can be executed from the requested CMake version. The CMake policies are set depending on the requested CMake version, cf. the documentation.
As a consequence, you have to test your code with the CMake in the version given in cmake_minimum_required and hope to catch all relevant code paths.

Upvotes: 2

Related Questions