On 10/26/06, Matthew Campbell <[EMAIL PROTECTED]> wrote:
Hey guys, So to warn you, this is really more of a regular expression question than a cmake question but since the problem is in a cmake script I thought you guys may cut me some slack. J In any case, I have a situation where my source directory contains the following: Something.cpp SomethingElse.cpp File_Win32.cpp File_Linux.cpp File_Mac.cpp What I want to do is glob for all files not having an _Win32, or a _Linux, etc. and then in the cmake script based on which OS I'm on, glob for the appropriate OS specific files. I assuming CMake can support this just fine since I believe FILE (GLOB []) takes a regular expression. Could someone tell me what the regex. Is for this operation? The results should be: PLATFORM_INDEPENDENT_SOURCES = Something.cpp SomethingElse.cpp WIN32_SOURCES = File_Win32.cpp The PLATFORM_INDEPENDENT_SOURCES is the part I am having troubles with figuring out the regular expression for.
Globbing is quiet different from regular expressions. I guess FILE(GLOB variable expression) has the same behavior than the shell globbing: http://www.gnu.org/software/bash/manual/bashref.html#SEC34 I guess extended patterns available in bash (with the `extglob' shell option) are not managed by CMake. So as you can see, it is far from beeing as powerful as regular expressions. But we can use the strength of CMake: # ----------------------------------------------------------------------------- FILE(GLOB Mac_CPP "*_Mac.cpp") FILE(GLOB Win32_CPP "*_Win32.cpp") FILE(GLOB Linux_CPP "*_Linux.cpp") FILE(GLOB Common_CPP "*.cpp") LIST(REMOVE_ITEM Common_CPP ${Mac_CPP} ${Win32_CPP} ${Linux_CPP}) MESSAGE(SEND_ERROR " Mac Sources: ${Mac_CPP} Win32 Sources: ${Win32_CPP} Linux Sources: ${Linux_CPP} Common Sources: ${Common_CPP}") # ----------------------------------------------------------------------------- I don't see how to make 'globbing' patterns which can: - find .h and .cpp - find files which do NOT contain a specific pattern. I'm interesting if you see a way to do it. ==> you have to duplicate entries for each set of files: FILE(GLOB Mac_CPP "*_Mac.cpp") FILE(GLOB Mac_H "*_Mac.h") LIST(APPEND Mac_Sources ${Mac_CPP} ${Mac_H}) I hope this will help you. -- Tristan Carel http://tristan-carel.com One of the keys to happiness is a bad memory. _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake