I would like to target a specific version of CMake that is older than the version I am using myself (related to this question, i.e. correctly using cmake_minimum_required()
), and it would be nice to be able to determine which features to stay away from, for instance.
Is it possible to find the first version that a certain feature (variable, function, property, ...) was introduced in CMake?
As far as I can tell, the CMake documentation does not directly include this information (except for indirectly via the release notes). A great example of how this could work is the Qt API documentation (e.g. see the documentation for QCryptographicHash).
EDIT: I created a git repo with a modified version of the solution provided by Florian: https://github.com/mbitsnbites/cmake-minver
I made a firefox plugin, named
CSince
, available in https://addons.mozilla.org/firefox/addon/csince/.When viewing a page of CMake documentation, it checks since which version the corresponding feature exists, and adds the information to the html contents.
A first checking is performed for versions starting with v3.0: the url pattern is checked for prior versions until a 404 error is returned by the server. For example, considering url for property
BINARY_DIR
:Here urls are tested replacing
latest
with a version string:Versions are tested using a dichotomic approach, to limit requests.
If the first checking process returns v3.0, a second pass is performed for older versions using a less reliable test: the single-page documentation is requested, and the feature string is searched in the text.
This two-passes system allows for example to find the right version for the property
BINARY_DIR
: the stringBINARY_DIR
obviously exists in CMake documentation v2.6, while it exists as a property only since CMake v3.7.Any bug report or improvement request are welcome. Code source is available on GitHub under license MIT/X11: https://github.com/wasthishelpful/csince.
After reading the comments here is my
CMake
version of a command/property/etc. checker:CMakeLists.txt
Would give for those examples I used for testing it:
Edit: Or if you e.g. run the above in script mode:
Reference