Skip to content

Commit

Permalink
Recompile the source code into different folder
Browse files Browse the repository at this point in the history
  • Loading branch information
nguy8tri committed Sep 17, 2024
1 parent 24c84fe commit 7036344
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST_FILES := $(filter-out $(CATCH_LIB)/%, $(TEST) $(TEST_H))

# Our Object source and test files
SRC_OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_SRC_DIR)/%.o,$(SRC))
TEST_OBJS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o,$(TEST)) $(filter-out %/main.o, $(SRC_OBJS))
TEST_OBJS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o,$(TEST)) $(filter-out %/main.o, $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o, $(SRC)))

# Our pre-processed source and test code
PRIVATE_SRC := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_PRIVATE_SRC_DIR)/%.i,$(SRC))
Expand Down Expand Up @@ -148,13 +148,16 @@ test_setup_message:
$(call PRINT_TARGET_HEADER, $(TEST_SETUP_TARGET))

# The test target
$(TEST_TARGET): $(TEST_SETUP_TARGET) $(COMPILE_TARGET) test_message $(TEST_BIN)
$(TEST_TARGET): $(TEST_SETUP_TARGET) test_message $(TEST_BIN)
valgrind ./$(TEST_BIN)
$(TEST_BIN): $(GTEST_DIR) $(TEST_OBJS) $(BIN_DIR)
$(CXX) $(CXXFLAGS_TEST) -o $(TEST_BIN) $(TEST_OBJS) $(LIBS) $(LDFLAGS_TEST)
$(BUILD_TEST_DIR)/%.o: $(TEST_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR)
mkdir -p $(@D)
$(CXX) $(TEST_LIBS) $(CXXFLAGS_TEST) -c $< -o $@
$(BUILD_TEST_DIR)/%.o: $(SRC_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR)
mkdir -p $(@D)
$(CXX) $(TEST_LIBS) $(CXXFLAGS_TEST) -c $< -o $@
$(GTEST_DIR): $(BUILD_DIR)
wget $(GTEST_URL)
tar -xzf $(GTEST_VERSION).tar.gz -C $(BUILD_LIBRARY_TEST_DIR)
Expand Down

0 comments on commit 7036344

Please sign in to comment.