This is my simple pre-make script for bootstrapping CMake for a small project
Make a new cpp project directory and download this Makefile
to your new project workspace via curl using the following commands :
$ mkdir my-new-project
$ cd my-new-project
$ curl -sSL \
-o Makefile \
--no-clobber \
https://gist.githubusercontent.com/brianonn/f10eaf000a4358478afb5b3cc8925b1d/raw/Makefile
$ make
When building with the Makefile
it will create the executable in build/main
.
I have the following alias defined as well. This will add a new alias cppboot
and make it easier to just invoke cppboot
in a new directory whenever you want to bootstrap a new cpp project on Linux:
alias cppboot='[ ! -e Makefile ] && curl -sSL -o Makefile https://gist.githubusercontent.com/brianonn/f10eaf000a4358478afb5b3cc8925b1d/raw/Makefile || echo "Makefile already exists in the current directory"'
After bootstrapping with the Makefile
you can remove the Makefile and replace it with build.sh
for a more advanced build environment with Debug and Release and Test support. The file build.sh
file is not always needed, but can be helpful for these more complex builds. Download build.sh
with curl too, if you want to use it.
$ rm -rf build
$ rm -rf Makefile
$ curl -sSL \
-o build.sh \
--no-clobber \
https://gist.githubusercontent.com/brianonn/f10eaf000a4358478afb5b3cc8925b1d/raw/build.sh
$ chmod 755 build.sh
$ ./build.sh
You can get help with ./build.sh -h
When building with build.sh
it will create the executables in build/Debug/main
and build/Release/main
build/
├── Debug
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── main
│ └── Makefile
├── Release
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── cmake_install.cmake
│ ├── main
│ └── Makefile
└── _THIS_DIR_CAN_BE_REMOVED_
premake5 - A more comprehensive and cross-platform/cross-architecture pre-make system.