Matthew, On Wed, Nov 19, 2008 at 5:56 PM, Matthew Woehlke <[EMAIL PROTECTED]> wrote: > 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.
Here's a macro I wrote and a discussion I started some time ago, http://www.cmake.org/pipermail/cmake/2008-May/021361.html It's probably pretty close to what you are looking to do. HTH, George. _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake