[CMake] problems detecting a required version of a library

Scott Amort jsamort at gmail.com
Wed Jun 28 13:02:34 EDT 2006


Hi Brad,

Thanks for the quick response.

Brad King wrote:
> What is the output value of "antlr-config --libs"?  What is the command
> you are using to store the value in the cache?

The output value is: /usr/lib64/libantlr.a on my AMD64 gentoo box.  I'm
not doing anything specific re: cache, here are the exact commands:

FIND_PROGRAM(ANTLR_CONFIG
  antlr-config
  /usr/bin
  /usr/local/bin
)

IF(ANTLR_CONFIG)

  EXECUTE_PROCESS(COMMAND ${ANTLR_CONFIG} --libs OUTPUT_VARIABLE
ANTLR_CONFIG_LIBS)

ENDIF(ANTLR_CONFIG)

...and later in a subdirectory's CMakeLists.txt,

TARGET_LINK_LIBRARIES(mylibrary ${ANTLR_CONFIG_LIBS})

If I output ANTLR_CONFIG_LIBS to a status message, it seems to throw an
end-of-line character into the output, which seems to be confusing the
cache used by TARGET_LINK_LIBRARIES.  It is the TARGET_LINK_LIBRARIES
that causes the actual problem, if I comment it out, everything works fine.

The actual error comes after a successful `cmake .', followed by `make':

CMake Error: Parse error in cache file (...)CMakeCache.txt. Offending
entry: ;

Here are the offending lines in CMakeCache.txt:

//Dependencies for the target
mylibrary_LIB_DEPENDS:STATIC=/usr/lib64/libantlr.a
;

I'm guessing the ; separator shouldn't be on a newline.

As a bit of experimentation, I discovered that by replacing the
EXECUTE_PROCESS with:

EXEC_PROGRAM(${ANTLR_CONFIG} ARGS --libs OUTPUT_VARIABLE ANTLR_CONFIG_LIBS)

The problem is fixed.  No end-of-line appears in ANTLR_CONFIG_LIBS (or
CMakeCache.txt), and the TARGET_LINK_LIBRARIES works just fine.

Perhaps a bug?

Best,
Scott



More information about the CMake mailing list