Taylor Bockman
5 years ago
1 changed files with 63 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||||
|
#! /usr/bin/env bash |
||||||
|
|
||||||
|
name=$1 |
||||||
|
cmake_version=$2 |
||||||
|
c_standard=$3 |
||||||
|
|
||||||
|
if [ -z $name ] |
||||||
|
then |
||||||
|
echo "Name must be specified" |
||||||
|
echo "" |
||||||
|
echo "./cgen.sh <name> [cmake version] [C Standard]" |
||||||
|
return -1 |
||||||
|
fi |
||||||
|
|
||||||
|
if [ -z $cmake_version ] |
||||||
|
then |
||||||
|
echo "No CMake version supplied...defaulting to 3.15" |
||||||
|
$cmake_version="3.15" |
||||||
|
fi |
||||||
|
|
||||||
|
if [ -z $c_standard ] |
||||||
|
then |
||||||
|
echo "No C Standard supplied...defaulting to 99" |
||||||
|
fi |
||||||
|
|
||||||
|
mkdir $name |
||||||
|
mkdir $name/src |
||||||
|
mkdir $name/include |
||||||
|
|
||||||
|
cmake_config=$name/CMakeLists.txt |
||||||
|
|
||||||
|
touch $cmake_config |
||||||
|
|
||||||
|
|
||||||
|
echo "cmake_minimum_required(VERSION $version)" >> $cmake_config |
||||||
|
echo "project($name)" >> $cmake_config |
||||||
|
echo "set (CMAKE_C_STANDARD $c_standard)" >> $cmake_config |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" |
||||||
|
echo "file(GLOB INCLUDE \${PROJECT_SOURCE_DIR}/include/*.h)" |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "include_directories(\${PROJECT_SOURCE_DIR}/include)" |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "# Controls debug printing based on the compiled binary mode - check with \#ifdef DEBUG_BUILD" >> $cmake_config |
||||||
|
echo "IF(CMAKE_BUILD_TYPE MATCHES DEBUG)" >> $cmake_config |
||||||
|
echo "message(\"-- Configuring debug build...\")" >> $cmake_config |
||||||
|
echo "add_compile_definitions(DEBUG_BUILD)" >> $cmake_config |
||||||
|
echo "ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)" >> $cmake_config |
||||||
|
echo "" >> $cmake_config |
||||||
|
echo "add_executable($name \${SOURCE} \${INCLUDE})" >> $cmake_config |
||||||
|
|
||||||
|
git --version 2>&1 >/dev/null |
||||||
|
GIT_IS_AVAILABLE=$? |
||||||
|
|
||||||
|
if [ $GIT_IS_AVAILABLE -eq 0 ] |
||||||
|
then |
||||||
|
git init $name |
||||||
|
fi |
||||||
|
|
||||||
|
echo "Created project $name." |
Loading…
Reference in new issue