Reputation: 1334
How does one achieve the equivalent of the cmake branch below for clang++?
if (GXX_VERSION VERSION_GREATER 4.5 OR GXX_VERSION VERSION_EQUAL 4.5)
...
Thanks,
Upvotes: 9
Views: 5009
Reputation: 33582
This works for me:
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.2)
...
...
endif ()
Similarly, we have VERSION_LESS
and VERSION_EQUAL
.
Upvotes: 5
Reputation: 11
Under cmake v3.1.3 I had to check CMAKE_CXX_COMPILER_VERSION as there was no CLANG_VERSION_STRING so looks like a version is now defined for each compiler type giving more control.
Upvotes: 1
Reputation: 1334
For some reason piokuc's solution doesn't work for me, so I did the following:
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
if (CLANG_VERSION_STRING VERSION_GREATER 3.1)
....
Upvotes: 10
Reputation: 26204
CMake defines following for clang:
Upvotes: 4