Any way in CMake to require GCC version 4+?

Use the try_compile() command and try to compile the following program.

Up vote 2 down vote favorite share g+ share fb share tw.

I am using some features that are provided in GCC v4+ and would like CMake to find GCC v4 compiler and if it does not find it, return an error stating GCC v4 is required. Anyone have any modules / ideas on how to do something like this? Thanks.

Gcc cmake link|improve this question asked Jan 12 '09 at 15:12RishiD222311 100% accept rate.

Use the try_compile() command and try to compile the following program #if __GNUC__! = 4 #error #endif int main() { return 0; }.

A wholly different (not necessarily better) way to implement a gcc version check would be something like: if(CMAKE_COMPILER_IS_GNUCXX) exec_program( ${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _compiler_output) string(REGEX REPLACE ". * (0-9\\.0-9\\.0-9) . *" "\\1" gcc_compiler_version ${_compiler_output}) message(STATUS "C++ compiler version: ${gcc_compiler_version} ${CMAKE_CXX_COMPILER}") if(gcc_compiler_version MATCHES "4\\.0-9\\.0-9") message(FATAL_ERROR "foobar") ... if(gcc_compiler_version VERSION_GREATER "4.5.99") ... ...

There's also the toolchain file, which is mentioned on the vtk wiki. That lets you specify custom toolchains. It's typically used for cross-compiling, but I've used it before to get other toolchains working.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions