[CMake] CMAKE_CXX_COMPILER_VERSION quite a useful variable, right?

Rolf Eike Beer eike at sf-mail.de
Thu May 14 12:31:51 EDT 2015


Am Donnerstag, 14. Mai 2015, 18:18:24 schrieb Niels Dekker - address until 
2018:
> When CMake (current version: 3.2.2) generates project files for Visual
> Studio, it appears to define an undocumented variable that seems quite
> useful to me: CMAKE_CXX_COMPILER_VERSION. It appears to be the full
> compiler version. For example, for my VS2010 installation,
> CMAKE_CXX_COMPILER_VERSION is "16.0.40219.1", and for my VS2013
> installation, CMAKE_CXX_COMPILER_VERSION is "18.0.31101.0".
> 
> It seems useful to me to pass this CMake variable to the resource
> compiler, which does not have direct access to the macro's predefined
> by the C++ compiler (like _MSC_FULL_VER and _MSC_BUILD), for example
> by adding a "-D" flag:
> 
> add_definitions(-DMY_COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}")
> 
> Do you agree that it would be a good idea to add
> CMAKE_CXX_COMPILER_VERSION to the list of useful CMake variables, at
> http://www.cmake.org/Wiki/CMake_Useful_Variables ?

$ cmake --help-variable 'CMAKE_<LANG>_COMPILER_VERSION'
CMAKE_<LANG>_COMPILER_VERSION
-----------------------------

Compiler version string.

Compiler version in major[.minor[.patch[.tweak]]] format.  This
variable is not guaranteed to be defined for all compilers or
languages.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150514/8839b549/attachment.sig>


More information about the CMake mailing list