[CMake] FW: cmake newbie questions

Phil Smith phil at voltage.com
Wed Aug 6 17:28:12 EDT 2008


I added the last line in the following block in CMakeDetermineCCompiler.cmake (insertion after line 69):

  LIST(LENGTH CMAKE_C_COMPILER _CMAKE_C_COMPILER_LIST_LENGTH)
  IF("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2)
    LIST(GET CMAKE_C_COMPILER 1 CMAKE_C_COMPILER_ARG1)
    LIST(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER)
  ENDIF("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2)
MESSAGE(STATUS "${CMAKE_C_COMPILER_ARG1}!")

And when I run it, I get only the exclamation point. So I don't think CMAKE_C_COMPILER is being set right.

In fact, I changed the MESSAGE to:
MESSAGE(STATUS "${CMAKE_C_COMPILER_ARG1}! length is !${_CMAKE_C_COMPILER_LIST_LENGTH}! compiler !${CMAKE_C_COMPILER}!")

and no matter whether I set the variable to two tokens, two tokens in one set of double quotes, or two tokens in two sets of double quotes, I get the same output:

-- ! length is !1! compiler !c:/progra~1/dignus/cc.bat!

So ARG1 is always null, which makes sense since length is always 1. Interesting that even with two tokens in one set of double quotes, the CMAKE_C_COMPILER variable is still set to just the first token.

...phsiii
-----Original Message-----
From: Alexander Neundorf [mailto:a.neundorf-work at gmx.net]
Sent: Wednesday, August 06, 2008 4:30 PM
To: Phil Smith
Cc: cmake at cmake.org
Subject: Re: [CMake] FW: cmake newbie questions

On Wednesday 06 August 2008, Phil Smith wrote:
> No errors, no CMakeError.log -- just null values for the SIZEOF_LONG_LONG
> et al.
>
> It sets CMAKE_C_COMPILER_ARG1 in CMakeDetermineCCompiler.cmake -- but
> inside: IF(NOT CMAKE_C_COMPILER)
>
> ...so it doesn't do it if you explicitly specify a C compiler, a la:
>         SET(CMAKE_C_COMPILER   "c:/progra~1/dignus/cc.bat -fasciiout")
>
> At least, that's how I read it.  After some fumbling, I put a MESSAGE
> before and inside that IF block, and only the one before gets triggered.

That's how it continues after the ELSE():

ELSE(NOT CMAKE_C_COMPILER)

  # we only get here if CMAKE_C_COMPILER was specified using -D or a pre-made
CMakeCache.txt
  # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
  # if CMAKE_C_COMPILER is a list of length 2, use the first item as
  # CMAKE_C_COMPILER and the 2nd one as CMAKE_C_COMPILER_ARG1

  LIST(LENGTH CMAKE_C_COMPILER _CMAKE_C_COMPILER_LIST_LENGTH)
  IF("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2)
    LIST(GET CMAKE_C_COMPILER 1 CMAKE_C_COMPILER_ARG1)
    LIST(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER)
  ENDIF("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2)

So set CMAKE_C_COMPILER to
SET(CMAKE_C_COMPILER   "c:/progra~1/dignus/cc.bat" "-fasciiout")
and then CMAKE_C_COMPILER_ARG1 should be set there.

Doesn't that work ?

Alex



More information about the CMake mailing list