Home > Back-end >  CMake way of wildcard values on set variables
CMake way of wildcard values on set variables

Time:01-06

I have the next snippet on a CMake based project

set(Headers
    ./include/MyLib/main.hpp
)
set(Sources
    src/main.cpp
)

add_library(${This} STATIC ${Headers} ${Sources})

How can I indicate to recursively include all the interface files under the:

  • ./include/MyLib/{ /* File name here */ }.ixx

and all the source files under the

  • src/{ /* File name here */ }.cpp

CodePudding user response:

One solution is to replace set() by:

file(
  GLOB_RECURSE
  Headers
  ./include/MyLib/*.ixx
)

and same thing for your source files.

  •  Tags:  
  • Related