0

Refer to this: How do I exclude a single file from a cmake `file(GLOB ... )` pattern?

How to exclude multiple files in a single exclude regex command?

Thank You

mv402506
  • 9
  • 4

1 Answers1

1

How to exclude multiple files in a single exclude regex command?

Simply write a regex that matches multiple files. Remember about double escaping in CMake.

list(FILTER lib_srcs EXCLUDE REGEX "^(file1|file2|file3)$")

Consider doing a function (untested, written here):

function(exclude_from_lsit list)
   foreach(ii IN LISTS ARGV)
       list(REMOVE_ITEM ${list} ${ii})
   endforeach()
   set(${list} ${${list}} PARENT_SCOPE)
endfunction()
exclude_from_list(lib_srcs
   file1
   file2
   file3
)

or just a loop really:

foreach(ii IN ITEMS
    file1
    file2
)
     list(REMOVE_ITEM lib_srcs ${ii})
endforeach()
KamilCuk
  • 120,984
  • 8
  • 59
  • 111