Skip to content

gagoel/cppprojecttemplate

Repository files navigation

CPP PROJECT TEMPLATE
--------------------

This is 'c++ project template' project, which provides basic layout of c++
project. It provides configuration properties and build properties, which can
be change in 'config_properties.m4' and 'build_properties.mk' files 
respectively.

Configuration Properties -
--------------------------

Global Project name string
PROJECT_NAME='[projectname]'

Global Project name string in caps
PROJECT_NAME_CAPS='[PROJECTNAME]'

Current directory
abs_current_dir=`pwd`

Project sources top directory. This is the reference directory for all file 
searches while building, installing and packaging.
abs_project_dir=`(cd $srcdir && pwd)`

Project build top directory. This is the reference directory for all build 
directories.
abs_build_dir=$abs_current_dir/build

Project install top directory. If $prefix was not set while configuration. It
would be "/usr/local/$PROJECT_NAME" default.
abs_install_dir=$prefix

Global Project version number.
major.minor.bug-fixes.port<release type>
major - new feature may be not compatible with older version
minor - new feature, bug fixes, fully compatible with older version
bug-fixes - only bug fixes.
port - platform type 0 - linux64
release-type - a - alpha, b - beta, g - gama
PROJECT_VERSION='1.0.0.0b'

Project root directory identification file. This file identify that we are 
running configuration in the right directory.
PROJECT_IDFILE='ABOUT_[PROJECTNAME]'

Project license string.
PROJECT_LICENSE='TODO - Add project license.'

Project distributable file name.
PROJECT_PACKAGE_NAME="$PROJECT_NAME"-"$PROJECT_VERSION"

Project configuration header file which has definition of all the variables
and can be included in project and used.
PROJECT_CONFIG_HEADERS="$abs_project_dir/include/config_options.h"

Project configuration file, If file name is XYZ here you should have XYZ.in
in your source directory. autoconf parse XYZ.in file, replace all variable
of type @VARIABLE@ and generate XYZ file.
PROJECT_CONFIG_FILES='Makefile'

Command line settings for optional features.
AC_ARG_ENABLE([cpplogger-vvlogging], [AS_HELP_STRING(
[--enable-cpplogger-vvlogging], \
[enable cpplogger very verbose logging. logs info and debug messages also.])],\
[AS_VAR_APPEND([CXXFLAGS],[" -DCPPLOGGER_VVLOGGING"])], [])

Command line settings for optional packages.
AC_ARG_WITH([input-value], [AS_HELP_STRING([--with-optional-package], \
[with or without optional package setting.])], \
[AS_VAR_SET([your_variable_name], [$with_input_value])], \
[AS_VAR_SET([your_variable_name], [no])])

Build Properties
----------------

# Important Points -
# 1. All directories paths are relative.
# 2. Files will be search within the directory and all its subdirectories
# recursively.
# 3. If any new directory created or existing directory modified, make sure
#    you update corresponding variable entry.
# 4. For mutliple directories, directories should be separated by space char.
# 5. Directory should not have '/' char at end.

#############################################################################
# Project source directories structure. 
# Relative path to - $abs_project_dir (top directory of project root).
#
# PROJECT_SRC_DIRS - all source files inside these directories will compile
# and generate object file with the name <filename>.o
#
# PROJECT_HEADERS_DIRS - these directories will be add in header files 
# serach path while compiling source code.
#
# PROJECT_EXEC_SRC_FILES - these files has the main method and will generate
# executable files.
#
# PROJECT_API_HEADERS_DIRS - all headers files inside these directories
# will be installed, installation path will be relative to the given
# path.
#
# PROJECT_EXTRA_FILES_DIRS - all files inside these directories will
# be install.
#
# PROJECT_DIST_DIRS - directories which needs to be part of distributable.
# file searches are recursive in these directories.
#############################################################################
PROJECT_SRC_DIRS = src 
PROJECT_HEADERS_DIRS = include
PROJECT_EXEC_SRC_FILES =
PROJECT_API_HEADERS_DIRS = include
PROJECT_EXTRA_FILES_DIRS = config logs
PROJECT_DIST_DIRS = config examples include src tests logs external \
ABOUT_PROJECTNAME acinclude.m4 build_properties.mk config_properties.m4 \
configure configure.ac DEV-README INSTALL Makefile.in QUESTION_ANSWER README \
TODO

#############################################################################
# Project tests source directories structure. 
# Relative path to - $abs_project_dir (top directory of project root).
#
# PROJECT_TESTS_SRC_DIRS - all tests source files inside these directories 
# will be compile and generate object file with the name <filename>.o
#
# PROJECT_TESTS_HEADERS_DIRS - these directories will be add in header files 
# serach path while compiling tests source code.
#
# PROJECT_TESTS_EXEC_SRC_FILES - these files has the main method and will 
# generate executable files.
#
# PROJECT_TESTS_EXTRA_FILES_DIRS - all files inside these directories will
# be used while running testcases.
#############################################################################
PROJECT_TESTS_SRC_DIRS = tests/src
PROJECT_TESTS_HEADERS_DIRS =
PROJECT_TESTS_EXEC_SRC_FILES = tests/main_test.cpp
PROJECT_TESTS_EXTRA_FILES_DIRS = tests/config

#############################################################################
# Project build directories structure. 
# Relative path to - $abs_build_dir (top directory of project build)/build.
#############################################################################
PROJECT_BUILD_OBJS_DIR = objs
PROJECT_BUILD_LIBS_DIR = libs
PROJECT_BUILD_BIN_DIR = bin

#############################################################################
# Project tests build directories structure. 
# Relative path to - $abs_build_dir (top directory of project build)/build.
#############################################################################
PROJECT_TESTS_BUILD_OBJS_DIR = tests/objs
PROJECT_TESTS_BUILD_LIBS_DIR = tests/libs
PROJECT_TESTS_BUILD_BIN_DIR = tests/bin
PROJECT_TESTS_BUILD_EXTRA_FILES_DIR = tests/config

#############################################################################
# Project install directories structure.
# Relative path to - $abs_install_dir (top directory of project install).
#############################################################################
PROJECT_INSTALL_BIN_DIR = bin
PROJECT_INSTALL_LIBS_DIR = lib
PROJECT_INSTALL_API_HEADERS_DIR = . 
PROJECT_INSTALL_EXTRA_FILES_DIR = share/$(PROJECT_NAME)

#############################################################################
# Project compilation flags. These flags have some default entries if you need
# to customize more, make sure you update entries here.
# Default entries are -
# CPPFLAGS - -fPIC -Wall -Wextra
# CXXFLAGS - -std=c++11
# LIBS - 
# INCLUDE_FLAGS - all project headers top directories entries
# LDFLAGS -
#############################################################################
#EXTRA_INCLUDE_FLAGS := -I/home/gagoel/gagoel_ggpw/tools/include
#EXTRA_CPPFLAGS := 
#EXTRA_CXXFLAGS := 
#EXTRA_LDFLAGS := -L/home/gagoel/gagoel_ggpw/tools/lib
#EXTRA_LIBS := -lcurl -lcpplogger -ldl
#EXTRA_TESTS_LIBS := /home/gagoel/gagoel_ggpw/tools/lib/gtest.a
#EXTRA_LD_LIBRARY_PATH := /home/gagoel/gagoel_ggpw/tools/lib

EXTRA_INCLUDE_FLAGS := 
EXTRA_CPPFLAGS := 
EXTRA_CXXFLAGS := 
EXTRA_LDFLAGS :=
EXTRA_LIBS := -lcurl -ldl
EXTRA_LD_LIBRARY_PATH :=

##############################################################################
# External packages configuration variables.
##############################################################################
GTEST_ROOT_DIR := $(abs_project_dir)/external/gtest
EXTRA_TESTS_IFLAGS := -I$(GTEST_ROOT_DIR)/include -I$(GTEST_ROOT_DIR)/include/gtest
EXTRA_TESTS_LIBS := $(GTEST_ROOT_DIR)/build/objs/gtest-all.o

CPPLOGGER_ROOT_DIR := $(abs_project_dir)/external/cpplogger
CPPLOGGER_INSTALL_ROOT_DIR := $(CPPLOGGER_ROOT_DIR)/install
EXTRA_LIBS += -lcpplogger
EXTRA_LDFLAGS += -L$(CPPLOGGER_INSTALL_ROOT_DIR)/lib
EXTRA_LD_LIBRARY_PATH += $(CPPLOGGER_INSTALL_ROOT_DIR)/lib
EXTRA_INCLUDE_FLAGS += -I$(CPPLOGGER_INSTALL_ROOT_DIR)/include

About

CPP PROJECT TEMPLATE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published