Hi Jin On 25. Mar, 2010, at 9:06 , Jin Huang wrote:
> Dear all, > > I am a newbie of cmake, and have googled some times for this question. I'm > sorry if it's a naive question. > > The typical operation is to make replacement on each string in a list. In > GNU Make, I can use the following code for such tasks: > > HEADER = $(patsubst %.cpp, %.h, $(SRC)) > HEADER_WITH_DIR = $(patsubst %, include/%, $(HEADER)) In GNU Make you probably should do this with $(addprefix include/, $(HEADER)) > > Now I can only use foreach iteration to construct a new list in CMake. Is > there any simple command to do this? > > Best regards, > > Jin set(SRC hello.cpp bla.cpp blu.cpp) string(REGEX REPLACE "\\.cpp(;|$)" ".h\\1" HEADER "${SRC}") string(REGEX REPLACE "([^;]+)(;|$)" "include/\\1\\2" HEADER_WITH_DIR "${HEADER}") message("HEADER = ${HEADER}") message("HEADER_WITH_DIR = ${HEADER_WITH_DIR}") HTH Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake