[CMake] cmake 2.4.7 not setting default flags for C compiler with ICC

Wheeler, Frederick W (GE, Research) wheeler at crd.ge.com
Tue Jan 22 08:49:00 EST 2008


I've noticed that cmake 2.4.7 does not set the flags for the different
build
types (Debug, Relase, etc.) for the icc (Intel) C compiler (cache
variables CMAKE_C_FLAGS_*).  I've made a simple test case below that
shows these flags getting set for gcc, but not icc.  The flags for the
C++ compiler get set properly for both g++ and icpc (Intel C++
compiler).

To get right to the issue, search for CMAKE_C_FLAGS_RELEASE below.  It
is set when CC=gcc, but not for CC=icc.

I discovered this when debugging an icc VXL build.  Code compiled from
C did not have any debug information because CMAKE_C_FLAGS_DEBUG was
empty.  A simple workaround is to set CMAKE_C_FLAGS to the flags you
need, but I assume this is still a bug worth fixing.

Fred Wheeler


#### system info ####

ssh magellan
uname -a

Linux magellan 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686
i686 i386 GNU/Linux

cmake --version

cmake version 2.4-patch 7

# sets PATH, LD_LIBRARY_PATH, etc. for icc
. /software/comp_intel/compiler90/x86/bin/iccvars.sh

icc -V
Intel(R) C Compiler for 32-bit applications, Version 9.1    Build
20070215Z Package ID: l_cc_c_9.1.047
Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

icpc -V
Intel(R) C++ Compiler for 32-bit applications, Version 9.1    Build
20070215Z Package ID: l_cc_c_9.1.047
Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

#### gcc test ####

rm -rf ~/tmp
mkdir ~/tmp
cd ~/tmp

touch CMakeLists.txt

CC=gcc CXX=g++ cmake \
  -G "Unix Makefiles" \
  .

-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Configuring done
-- Generating done# sets PATH, LD_LIBRARY_PATH, etc. for icc
. /software/comp_intel/compiler90/x86/bin/iccvars.sh

-- Build files have been written to: /home/wheeler/tmp

grep 'CMAKE_C.*COMPILER.*FILEPATH' CMakeCache.txt 

CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc

grep 'CMAKE_C.*FLAGS.*STRING' CMakeCache.txt 

CMAKE_CXX_FLAGS:STRING=' '
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g
CMAKE_C_FLAGS:STRING=' '
CMAKE_C_FLAGS_DEBUG:STRING=-g
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g

#### icc test ####

rm -rf ~/tmp
mkdir ~/tmp
cd ~/tmp

touch CMakeLists.txt

CC=icc CXX=icpc cmake \
  -G "Unix Makefiles" \
  .

-- Check for working C compiler: /opt/intel/compiler90/x86/bin/icc
-- Check for working C compiler: /opt/intel/compiler90/x86/bin/icc --
works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /opt/intel/compiler90/x86/bin/icpc
-- Check for working CXX compiler: /opt/intel/compiler90/x86/bin/icpc --
works
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wheeler/tmp

grep 'CMAKE_C.*COMPILER.*FILEPATH' CMakeCache.txt 

CMAKE_CXX_COMPILER:FILEPATH=/opt/intel/compiler90/x86/bin/icpc
CMAKE_C_COMPILER:FILEPATH=/opt/intel/compiler90/x86/bin/icc

grep 'CMAKE_C.*FLAGS.*STRING' CMakeCache.txt 

CMAKE_CXX_FLAGS:STRING=' '
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g
CMAKE_C_FLAGS:STRING=' '
CMAKE_C_FLAGS_DEBUG:STRING=
CMAKE_C_FLAGS_MINSIZEREL:STRING=
CMAKE_C_FLAGS_RELEASE:STRING=
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=

###### end ####

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20080122/153490fe/attachment-0001.htm


More information about the CMake mailing list