如何在 Windows 上移植 $(shell find . -name '*.cpp') ?

如何在 Windows 上移植 $(shell find . -name '*.cpp') ?

我在 makefile 中有這個:

# find cpp files in subdirectories
SOURCES := $(shell find . -name '*.cpp')

所以我想製作FIND在 Windows 和 Linux 上運行正常的通用命令:

ifeq ($(OS),Windows_NT)
   # WINDOWS
   RM = erase /Q
   FIND = ???
else
   # LINUX
   ifeq ($(shell uname), Linux)
      RM = rm -f
      # This is probably wrong too, but I have no idea how to do it right
      FIND = $(find . -name '$1')
   endif
endif

當然,我甚至不知道如何為linux製作參數化查找模板。但更重要的是,我找不到按模式找到所有文件的命令。 Windows 有這個:

dir * /s/b | findstr \.cpp$

這很漂亮,但是使用正則表達式...我如何正確移植它,以便 find 在兩個系統上都表現良好? makefile 沒有自己的查找文件的方法嗎?

相關內容