Set CMAKE_BUILD_TYPE to Release if empty

Make based single-configuration generators default to an empty build
type, if that is the case set it to Release instead. Also add an
option to disable this behavior in case someone needs the default
empty build type.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9537b7b..3116e0f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,21 @@
   option(ZOPFLI_BUILD_INSTALL "Add Zopfli install target" OFF)
 endif()
 
+# ZOPFLI_DEFAULT_RELEASE enables changing empty build type to Release
+#
+# Make based single-configuration generators default to an empty build type,
+# which might be surprising, but could be useful if you want full control over
+# compiler and linker flags. When ZOPFLI_DEFAULT_RELEASE is ON, change an
+# empty default build type to Release.
+option(ZOPFLI_DEFAULT_RELEASE "If CMAKE_BUILD_TYPE is empty, default to Release" ON)
+
+if(zopfli_standalone AND ZOPFLI_DEFAULT_RELEASE)
+  if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+    message(STATUS "CMAKE_BUILD_TYPE empty, defaulting to Release")
+    set(CMAKE_BUILD_TYPE Release)
+  endif()
+endif()
+
 #
 # Library version
 #
@@ -45,12 +60,6 @@
 set(ZOPFLI_VERSION_PATCH 2)
 set(ZOPFLI_VERSION "${ZOPFLI_VERSION_MAJOR}.${ZOPFLI_VERSION_MINOR}.${ZOPFLI_VERSION_PATCH}")
 
-if(zopfli_standalone)
-  if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
-    message(STATUS "Zopfli build type is default (CMAKE_BUILD_TYPE empty)")
-  endif()
-endif()
-
 if(ZOPFLI_BUILD_SHARED)
   set(zopfli_library_type SHARED)
 else()