Problem when source and object files are in different paths

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem when source and object files are in different paths

David Aldrich-4
Hi

My project looks like:

├── build
│   |── makefile
|
└── src
    ├── subsys1
    │   ├── includes
    │   └── src_1.cpp
    └── subsys2
        ├── includes
        └── src_2.cpp

I want the object files and executable to be stored in the build directory.

My makefile has:

OBJDIR = _gnuRelease

CPP_FILES = ../src/subsys1/src_1.cpp ../src/subsys1/src_2.cpp

OBJ_FILES_TMP = $(patsubst %.cpp,%.o,$(CPP_FILES))
OBJ_FILES = $(addprefix $(OBJDIR)/,$(notdir $(OBJ_FILES_TMP)))

$(APP) : $(OBJ_FILES)
        $(LINKER) $(CXXFLAGS) $^ -o $@

%.o: %.cpp
        $(CXX) $(CXXFLAGS) $(INC_SWITCHES) -c $< -o $@

Best regards

David


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make