CMake .gitignore build directory

CMake can place a .gitignore file in the build directory to allow making build directories with arbitrary names not cause clutter. Many projects have a project-wide .gitignore containing:

build*/

but some users like to use bin/ etc. instead.

Make this more flexible by putting a .gitignore in the build directory, regardless of name by putting in CMakeLists.txt:

# --- auto-ignore build directory
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
  file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*")
endif()