Browse Source

cgen.sh now writes a valid CMake C project

Taylor Bockman 5 years ago
parent
commit
dba29a130a
  1. 13
      dotfiles/bash/scripts/cgen.sh

13
dotfiles/bash/scripts/cgen.sh

@ -15,12 +15,13 @@ fi
if [ -z $cmake_version ] if [ -z $cmake_version ]
then then
echo "No CMake version supplied...defaulting to 3.15" echo "No CMake version supplied...defaulting to 3.15"
$cmake_version="3.15" cmake_version="3.15"
fi fi
if [ -z $c_standard ] if [ -z $c_standard ]
then then
echo "No C Standard supplied...defaulting to 99" echo "No C Standard supplied...defaulting to 99"
c_standard="99"
fi fi
mkdir $name mkdir $name
@ -32,16 +33,16 @@ cmake_config=$name/CMakeLists.txt
touch $cmake_config touch $cmake_config
echo "cmake_minimum_required(VERSION $version)" >> $cmake_config echo "cmake_minimum_required(VERSION $cmake_version)" >> $cmake_config
echo "project($name)" >> $cmake_config echo "project($name)" >> $cmake_config
echo "set (CMAKE_C_STANDARD $c_standard)" >> $cmake_config echo "set (CMAKE_C_STANDARD $c_standard)" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" echo "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" >> $cmake_config
echo "file(GLOB INCLUDE \${PROJECT_SOURCE_DIR}/include/*.h)" echo "file(GLOB INCLUDE \${PROJECT_SOURCE_DIR}/include/*.h)" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "include_directories(\${PROJECT_SOURCE_DIR}/include)" echo "include_directories(\${PROJECT_SOURCE_DIR}/include)" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "" >> $cmake_config echo "" >> $cmake_config
echo "# Controls debug printing based on the compiled binary mode - check with \#ifdef DEBUG_BUILD" >> $cmake_config echo "# Controls debug printing based on the compiled binary mode - check with \#ifdef DEBUG_BUILD" >> $cmake_config
@ -59,7 +60,7 @@ echo ""
echo "" echo ""
echo "int main(int argc, char **argv)" >> $sample_file echo "int main(int argc, char **argv)" >> $sample_file
echo "{" >> $sample_file echo "{" >> $sample_file
echo " printf(\"Hello, world!\\n\")" >> $sample_file echo " printf(\"Hello, world!\\n\");" >> $sample_file
echo " return 0;" >> $sample_file echo " return 0;" >> $sample_file
echo "}" >> $sample_file echo "}" >> $sample_file
echo "" >> $sample_file echo "" >> $sample_file

Loading…
Cancel
Save