[CMake] Detecting Compiler
James Bigler
bigler at cs.utah.edu
Wed Jun 6 12:14:26 EDT 2007
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
More information about the CMake
mailing list