I know that in CMake I can check for the compiler version like this
if(MSVC_VERSION LESS 1700)
... // MSVC is lower than MSVC2012
but how do I express this in CMake syntax?
if(MSVC_VERSION GREATER_OR_EQUAL_TO 1700)
... // MSVC greater or equal to MSVC2012
Update for CMake 3.7 and later:
CMake 3.7 introduced a couple of new comparisons for if
, among them GREATER_EQUAL
:
if(MSVC_VERSION GREATER_EQUAL 1700)
[...]
Original answer for older CMake versions:
if((MSVC_VERSION GREATER 1700) OR (MSVC_VERSION EQUAL 1700))
[...]
Or probably better, as it avoids repeating the condition:
if(NOT (MSVC_VERSION LESS 1700))
[...]
Maybe use VERSION_GREATER_EQUAL
? (This was also introduced in CMake 3.7.)
I.e.:
if (MSVC_VERSION VERSION_GREATER_EQUAL 1700)
# [...]
VERSION_GREATER_EQUAL and VERSION_LESS_EQUAL also support multipart version identifiers, such as 14.1.0, comparing these correctly as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With