Browse Source

cgen.sh now writes a valid CMake C project

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

13
dotfiles/bash/scripts/cgen.sh

@ -15,12 +15,13 @@ fi
if [ -z $cmake_version ]
then
echo "No CMake version supplied...defaulting to 3.15"
$cmake_version="3.15"
cmake_version="3.15"
fi
if [ -z $c_standard ]
then
echo "No C Standard supplied...defaulting to 99"
c_standard="99"
fi
mkdir $name
@ -32,16 +33,16 @@ cmake_config=$name/CMakeLists.txt
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 "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 "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" >> $cmake_config
echo "file(GLOB INCLUDE \${PROJECT_SOURCE_DIR}/include/*.h)" >> $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 "# Controls debug printing based on the compiled binary mode - check with \#ifdef DEBUG_BUILD" >> $cmake_config
@ -59,7 +60,7 @@ echo ""
echo ""
echo "int main(int argc, char **argv)" >> $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 "}" >> $sample_file
echo "" >> $sample_file

Loading…
Cancel
Save