MURICA213
MURICA213

Reputation: 17

how to exclude a sub directory from cmake file

I am using cmake and in dir i have lot of sub-dir something like this

main_dir

 - sub_dir_a
 - sub_dir_b
 - sub_dir_c
    .
    .
 - sub_dir_z

Lets say i need to include all sub-dir except "sub_dir_z" and in cmake I use the command

target_include_directories

Instead of including every seperate sub-dir and leaving out "sub_dir_z", is there any command such that i simply do target_include_directories on "main_dir" and exclude "sub_dir_z"

Upvotes: 1

Views: 1796

Answers (1)

ixSci
ixSci

Reputation: 13698

There is no command for it, afaik. But you can implement it yourself pretty easily by combining other commands. Something like this:

file(GLOB SUB_FOLDERS LIST_DIRECTORIES true "*")
list(FILTER SUB_FOLDERS EXCLUDE REGEX "sub_dir_z")
target_include_directories(YourTarget PRIVATE ${SUB_FOLDERS})

Upvotes: 3

Related Questions