Search code examples
cmakeglob

Match all non-python files in /dir


Whit globbing expressions on cmake, /dir/*.py - match all python files in /dir

But how I do the opposit? Match all non-py files


Solution

  • Match all files and then remove the the python files, i.e.:

    file(
        GLOB_RECURSE _pythonFiles
        RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
        "${CMAKE_CURRENT_SOURCE_DIR}/dir/*.py")
    file(
        GLOB_RECURSE _nonPythonFiles 
        RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
        "${CMAKE_CURRENT_SOURCE_DIR}/dir/*.*")
    list(REMOVE_ITEM _nonPythonFiles ${_pythonFiles})