program story

cmake`file (GLOB…)`패턴에서 단일 파일을 제외하려면 어떻게해야합니까?

inputbox 2020. 10. 27. 08:09
반응형

cmake`file (GLOB…)`패턴에서 단일 파일을 제외하려면 어떻게해야합니까?


CMakeLists.txt내용은 다음과 같습니다.

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

그리고 IlmImf폴더를 포함 b44ExpLogTable.cpp내가 빌드에서 제외해야한다.

그것을 달성하는 방법?


list함수를 사용하여 목록을 조작 할 수 있습니다. 예를 들면 다음과 같습니다.

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

귀하의 경우에는 다음과 같이 작동합니다.

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

FILTER는 경우에 따라 더 편리 할 수있는 또 다른 옵션입니다.

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).

참고 URL : https://stackoverflow.com/questions/15550777/how-do-i-exclude-a-single-file-from-a-cmake-fileglob-pattern

반응형