[CMake] cmake version/feature detection

David Cole dlrdave at aol.com
Thu Aug 7 07:55:50 EDT 2014


Specifically, for the OBJECT library feature, I figured out what
version of CMake introduced it like this:

    gitk -- Tests/ObjectLibrary/CMakeLists.txt

leads to finding this first commit of that file: 69d3d183 [1]

    gitk 69d3d183

leads to b87d7a60 [2] (4 parent commits up) which introduced the
feature itself. Then,

    git describe --contains b87d7a60

yields:

    v2.8.8~29^2~15

So.... OBJECT libraries were introduced in CMake v2.8.8. Also, in all
the gitk views for these commits, it tells you "Follows: v2.8.7" and
"Precedes: v2.8.8".


You could therefore write code like:

    if (${CMAKE_VERSION} VERSION_LESS 2.8.8)
      # avoid OBJECT libraries
    else()
      # ok to use OBJECT libraries
    endif()


HTH,
David C.


[1] http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69d3d183
[2] http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b87d7a60




More information about the CMake mailing list