[CMake] Cmake C compiler detection broken in some cases

Hendrik Sattler post at hendrik-sattler.de
Mon Jun 22 01:54:38 EDT 2009


Hi,

The following makes latest cmake-2.6.4 (and earlier versions) fail:
$ export CFLAGS="-Wall -Wextra -Werror"
$ cmake ..
-- The C compiler identification is GNU    
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-2.6/Modules/CMakeTestCCompiler.cmake:32 
(MESSAGE):
  The C compiler "/usr/bin/gcc" is not able to compile a simple test program.     

  It fails with the following output:

   Change Dir: /home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp



  Run Build Command:/usr/bin/make "cmTryCompileExec/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
  CMakeFiles/cmTryCompileExec.dir/build

  make[1]: Entering directory
  `/home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  /home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o

  /usr/bin/gcc -Wall -Wextra -Werror -o
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
  /home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp/testCCompiler.c

  cc1: warnings being treated as errors

  /home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp/testCCompiler.c:9:
  error: unused parameter ‘argv’

  make[1]: Leaving directory
  `/home/hendrik/tmp/cmake1/build/CMakeFiles/CMakeTmp'

  make[1]: *** [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o] Fehler 1

  make: *** [cmTryCompileExec/fast] Fehler 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (PROJECT)


-- Configuring incomplete, errors occurred!


Ok, -Wextra may be a unreal sometimes but cmake should work in such cases.
Adding a line like
  (void)argv;
like in CMakeCCompilerId.c.in solves the problem. Same game for C++ compiler.

HS



More information about the CMake mailing list