Search code examples
cmake

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


My CMakeLists.txt contains this line:

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

and the IlmImf folder contains b44ExpLogTable.cpp, which I need to exclude from the build.

How to achieve that?


Solution

  • You can use the list function to manipulate the list, for example:

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

    In your case, maybe something like this will work:

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