Can someone explain to me:
- why this doesn't work (prints "CFLAGS match broken!!")
- if it's supposed to work or if this is a bug
- a great work-around to this problem ;-)

This is with cmake 2.6.2

================================================
macro(foo bar)
  if("${bar}" MATCHES "CFLAGS")
    message(STATUS "CFLAGS matched")
  elseif("${bar}" STREQUAL "CFLAGS")
    message(STATUS "CFLAGS match broken!!!")
  endif()
endmacro()

function(nonce)
  foreach(arg ${ARGN})
    foo("${arg}")
  endforeach()
endfunction()

set(CFLAGS happyjoy)

foo(CFLAGS)
================================================

Background: I'm trying to write a function that is invoked like:

foobar(mylib CFLAGS -DFOO -DBAR SOURCES foo.c bar.c LINK_LIBRARIES mib)

Maybe there is some great mechanism for dealing with this sort of list-splitting that I don't know about? Meanwhile, what I am doing is something like this:

- For each arg, 'if("${ARG}" MATCHES "CFLAGS|SOURCES|LINK_LIBRARIES', set _arg_mode to ${arg}, otherwise based on ${_arg_mode}, do a list(APPEND) to one of _cflags, _sources, _libs.
- add_library(${NAME} ${_sources})
- do some target_link_libraries, set_target_properties based on _cflags, _libs, etc.

--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
Sendmail administration is not black magic. There are legitimate technical reasons why it requires the sacrifice of a live chicken.
  -- Unknown

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to