2013/1/8 Alan W. Irwin <ir...@beluga.phys.uvic.ca>: > On 2013-01-08 10:47+0100 Eric Noulard wrote: > >> 2013/1/8 Alan W. Irwin <ir...@beluga.phys.uvic.ca>: > > >> The rule should be simple as: >> >> You need to escape one time less than the number of cmake run occuring >> through the workflow path. >> In your case you have to escape once because install(CODE ...) is >> processed **by cmake** >> at "Install time" and you expect the evaluation to take place at that >> time. >> >> The may-be tricky part is "when" cmake (or derived cmake script engine >> is running) >> the "running time" of cmake tool suite may not be obvious and I tried >> to picture it in >> a tutorial (see excerpt attached to this mail) >> >> May be we can document common uses cases: >> >> install(CODE --> one escape >> install(SCRIPT --> none >> >> add_custom_command/target --> one or two level escape depending on the >> arguments >> >> with various combination where you may "configure_file" >> 1) yourself before using "install(SCRIPT ..." --> my way of work >> usually one escape level. >> >> 2) through CPack like values used in CPACK_xxx variable which end up >> in some CPack template file which are processed first at CMake-time >> and >> may be again at CPack-time. This one may lead to 2 level escape. >> > > Don't forget the example of code like this: > > set(CPACK_SOURCE_IGNORE_FILES > "\\\\#*\\\\#$" > "^${PROJECT_SOURCE_DIR}.*/\\\\.svn/" > .... > > I have been wrong about overcomplicating escapes in the past, but I > think it this case, 4 levels of escapes are really necessary for these > particular regex expressions. Anyhow, I know this code works, but I > don't know why! Does your simple rule above explain this, and if so how?
In my mind this sequence is a two-level one but you need four '\' because backslash **itself** need to be escaped at both level. level 1 = when cmake runs level 2 = when cpack runs and process CPACK_SOURCE_IGNORE_FILES. in the end you need to get '\.' so you need \\. at level 1 output thus \\\\. in the CMakeLists.txt -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers