[CMake] OS/Compiler Versioning for External Libs
Brad King
brad.king at kitware.com
Mon Jan 10 10:15:54 EST 2005
Brian Hone wrote:
> Now I need to set up external dependencies. Unfortunately, we support
> several OS's + compilers. Is there a right way to handle this?
>
> For instance, let's say I have library foo. I need to be able to link
> against:
>
> somedir/solaris-gcc-3.2.2/lib/libfoo.so and somedir/solaris-gcc-3.2.2/inc
> or
> somedir/solaris-cc/lib/libfoo.so
> or
> somedir/linux-gcc-3.3.3/lib/libfoo.so
> etc.
>
> My thinking is to try to grab the system/compiler version and put it
> into the link and include dirs, but I can't figure out how to get
> compiler version, only compiler name.
> Or am I thinking about this wrong?
This approach should work pretty well, but I have not seen it done
before with CMake. There is no standard way to get the compiler version
from CMake. Since there is no standard flag to get the version of a
compiler, I usually do it by writing a small source file that uses the
preprocessor to get the version:
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
printf("gcc-%d.%d.%d", __GNUC__,
__GNUC_MINOR__, __GNUC_PATCH_LEVEL__);
#elif ...
#endif
Then use the TRY_RUN command to get the output of the program.
I've considered creating a standard version of this kind of program to
include with CMake that has knowledge of many compilers, but it is not a
high priority right now.
-Brad
More information about the CMake
mailing list