generated from wessel/boilerplate-c
feat(repo): Move from C to CPP
This commit is contained in:
30
makefile
30
makefile
@@ -1,5 +1,5 @@
|
||||
# C compiler to use
|
||||
CC := gcc
|
||||
# C++ compiler to use
|
||||
CC := g++
|
||||
|
||||
# Directory mappings
|
||||
SRC_DIR := src
|
||||
@@ -9,12 +9,18 @@ OUT_DIR := out
|
||||
INC_DIR := include
|
||||
TST_DIR := test
|
||||
|
||||
# Map all object and source files
|
||||
SRC_FILES := $(wildcard $(SRC_DIR)/**/*.c) $(wildcard $(LIB_DIR)/**/*.c)
|
||||
OBJ_FILES := $(patsubst $(SRC_DIR)/**/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
|
||||
# Map all object and source files (C++)
|
||||
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/**/*.cpp) $(wildcard $(LIB_DIR)/*.cpp) $(wildcard $(LIB_DIR)/**/*.cpp)
|
||||
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(SRC_DIR)/%.cpp,$(SRC_FILES))) \
|
||||
$(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(SRC_DIR)/**/*.cpp,$(SRC_FILES))) \
|
||||
$(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/%.cpp,$(SRC_FILES))) \
|
||||
$(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/**/*.cpp,$(SRC_FILES)))
|
||||
|
||||
TST_FILES := $(wildcard $(TST_DIR)/*.c) $(wildcard $(LIB_DIR)/*.c)
|
||||
OBJ_TST_FILES := $(patsubst $(TST_DIR)/%.c,$(OBJ_DIR)/%.o,$(TST_FILES))
|
||||
TST_FILES := $(wildcard $(TST_DIR)/*.cpp) $(wildcard $(TST_DIR)/**/*.cpp) $(wildcard $(LIB_DIR)/*.cpp) $(wildcard $(LIB_DIR)/**/*.cpp)
|
||||
OBJ_TST_FILES := $(patsubst $(TST_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(TST_DIR)/%.cpp,$(TST_FILES))) \
|
||||
$(patsubst $(TST_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(TST_DIR)/**/*.cpp,$(TST_FILES))) \
|
||||
$(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/%.cpp,$(TST_FILES))) \
|
||||
$(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/**/*.cpp,$(TST_FILES)))
|
||||
|
||||
# All optional libs and Cflags to append to the final command
|
||||
LIBS :=
|
||||
@@ -27,12 +33,12 @@ WARNFLAGS := -Wall -Wextra -Wconversion
|
||||
.PHONY: clean help
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# Macro for creating object files
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) -c -o $@ $<
|
||||
# Macro for creating object files (C++)
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(TST_DIR)/%.c
|
||||
$(CC) -c -o $@ $<
|
||||
$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
## All make commands ##
|
||||
help: ## Lists all commands
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
/*
|
||||
Project description
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../../lib/util.h"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[], char *env[]) {
|
||||
std::cout << "yo!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user