aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoergen Ibsen <ji@ibse.dk>2018-08-31 08:24:47 +0200
committerJoergen Ibsen <ji@ibse.dk>2018-08-31 08:24:47 +0200
commitf01b29e3c57a2f541fcda85428c9f59aeffa7a31 (patch)
treef5fb0aa51c1830f32352ddda78fda0bc8b014115
parentf4261f201c55d7e69204fdc8d732f7a5098c8d25 (diff)
downloadzopfli-f01b29e3c57a2f541fcda85428c9f59aeffa7a31.tar.gz
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.
-rw-r--r--CMakeLists.txt21
1 files changed, 15 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9537b7b..3116e0f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,21 @@ else()
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_MINOR 0)
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()