0

is there a way to include all .cpp files in make? I tried this and it does not work

# the build command
error_app: error_reporting.cpp $(INCLUDE_PATH)%.cpp
    $(CC) $(CFLAGS) $^ -o $(DEBUG_PATH)$@.exe

is manually typing it the only way?

# the build command
error_app: error_reporting.cpp $(INCLUDE_PATH)error_checker.cpp $(INCLUDE_PATH)error_report.cpp
    $(CC) $(CFLAGS) $^ -o $(DEBUG_PATH)$@.exe
Andy An
  • 29
  • 5

1 Answers1

0

$(wildcard $(INCLUDE_PATH)/*.cpp).

There's also a recursive alternative to wildcard here if you want to include subdirectories as well.

Also, don't add .exe to output filenames. MinGW will add it automatically, and it's unnecessary on Linux. And don't forget .PHONY if your target name doesn't match the filename it generates.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207