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