Как исключить один файл из шаблона cmake `file(GLOB...)'?



мой CMakeLists.txt содержит следующую строку:



file(GLOB lib_srcs Half/half.cpp Iex/*.cpp IlmThread/*.cpp Imath/*.cpp IlmImf/*.cpp)



и содержит b44ExpLogTable.cpp, которые мне нужно исключить из сборки.



как этого добиться?

794   2  

2 ответов:

можно использовать list функция для управления списком, например:

list(REMOVE_ITEM <list> <value> [<value> ...])

в вашем случае, возможно, что-то вроде этого будет работать:

list(REMOVE_ITEM lib_srcs "IlmImf/b44ExpLogTable.cpp")

еще один вариант, который может быть более удобным в некоторых случаях:

list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>)

эта строка исключает каждый элемент, заканчивающийся требуемым именем файла:

list(FILTER lib_srcs EXCLUDE REGEX ".*b44ExpLogTable.cpp$")

здесь Спецификация Регулярных Выражений для cmake:

The following characters have special meaning in regular expressions:

^         Matches at beginning of input
$         Matches at end of input
.         Matches any single character
[ ]       Matches any character(s) inside the brackets
[^ ]      Matches any character(s) not inside the brackets
 -        Inside brackets, specifies an inclusive range between
          characters on either side e.g. [a-f] is [abcdef]
          To match a literal - using brackets, make it the first
          or the last character e.g. [+*/-] matches basic
          mathematical operators.
*         Matches preceding pattern zero or more times
+         Matches preceding pattern one or more times
?         Matches preceding pattern zero or once only
|         Matches a pattern on either side of the |
()        Saves a matched subexpression, which can be referenced
          in the REGEX REPLACE operation. Additionally it is saved
          by all regular expression-related commands, including
          e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).

Comments

    Ничего не найдено.