Add all files under a folder to a CMake glob?

前端 未结 1 729
眼角桃花
眼角桃花 2020-12-03 03:48

I\'ve just read this:

CMake - Automatically add all files in a folder to a target?

With the answer suggesting a file glob, e.g.:

file(GLOB \"         


        
相关标签:
1条回答
  • 2020-12-03 04:07

    Turning my comment into an answer

    If you want to add recursive searching for files use file(GLOB_RECURSE ...)

    file(GLOB_RECURSE source_list "*.cpp" "*.hpp")
    

    Your second example would translate into

    file(GLOB_RECURSE BAR "src/baz/*.cpp")
    

    References

    • file(...)
    • Specify source files globally with GLOB?
    0 讨论(0)
提交回复
热议问题