[CMake] Detecting Compiler

Pau Garcia i Quiles pgquiles at elpauer.org
Wed Jun 6 12:44:13 EDT 2007


Hello,

It'd nice if there was some king of "forge" to place all these  
FindFoo.cmake, UseBar.cmake and CheckFizzbuzz.cmake people are  
developing. There are lots of duplicate FindXXXX.cmake out there (I  
can count at least 5 FindBoost.cmake and that's for something which  
already comes with stock CMake).

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to the amount of work, I usually need 10 days to answer)



Quoting James Bigler <bigler at cs.utah.edu>:

> Hi,
>
> Mike Jackson wrote:
>> I looked and looked but I know it is simple but I just can not find  
>>  the answer:
>>
>> I want to add some flags given a certain compiler (like the intel   
>> compiler).. how should I proceed?
>>
>> IF (COMPILER matches INTEL) ?? Will that work?
>>
>> This is on OS X if that matters.
>>
>>
>> Also looking down in /usr/local/share/cmake/modules/platform I see   
>> a pair of Darwin.* files. Can we get one in there for the intel   
>> compilers for OS X? what information is needed to build one?
>
> CMake seems to come with built in detection of GCC, but not for other
> compilers (see Modules/CMakeDetermineCCompiler.cmake).
>
> This is what I use:
>
> IF(NOT CMAKE_COMPILER_IS_GNUCC)
>   # This regular expression also matches things like icc-9.1
>   IF   (CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
>     SET(USING_ICC TRUE)
>   ENDIF(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
> ELSE(NOT CMAKE_COMPILER_IS_GNUCC)
>   SET(USING_GCC TRUE)
> ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
>
> SET(MANTA_COMPILER_NAME_REGEXPR "icpc.*$")
> IF(NOT CMAKE_COMPILER_IS_GNUCXX)
>   IF   (CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
>     SET(USING_ICPC TRUE)
>
>     EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
>       ARGS --version
>       OUTPUT_VARIABLE TEMP)
>
>     STRING(REGEX MATCH "([0-9\\.]+)"
>       INTEL_COMPILER_VERSION
>       ${TEMP})
>
>     MARK_AS_ADVANCED(INTEL_COMPILER_VERSION)
>   ENDIF(CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
> ELSE(NOT CMAKE_COMPILER_IS_GNUCXX)
>   SET(USING_GPP TRUE)
> ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
>
>
> -------------------------------------
> James
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list