cmake: Correct the CMake build type check.
- Fix the argument order in the set() call. Clears this warning:
CMake Warning (dev) at CMakeLists.txt:15 (set):
implicitly converting 'Build type: Debug, Release, RelWithDebInfo or
MinSizeRel' to 'STRING' type.
This warning is for project developers. Use -Wno-dev to suppress
it.
- Ignore CMAKE_BUILD_TYPE when CMAKE_CONFIGURATION_TYPES is set:
when CMAKE_CONFIGURATION_TYPES is set a multi configuration
generator is in use, and CMake ignore CMAKE_BUILD_TYPE.
- Defer the build type check until after the project() command runs:
CMAKE_CONFIGURATION_TYPES is not set until project() returns.
Change-Id: I81acba1ede5817722955a634783b92a5551d6690
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f7e11c..c0e4463 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,18 +9,17 @@
# can obtain it at www.aomedia.org/license/patent.
#
cmake_minimum_required(VERSION 3.5)
+project(AOM C CXX)
if(NOT EMSCRIPTEN)
- if(NOT CMAKE_BUILD_TYPE)
+ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE
"Release"
- CACHE "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING
+ CACHE STRING "Build type: Debug, Release, RelWithDebInfo or MinSizeRel"
FORCE)
endif()
endif()
-project(AOM C CXX)
-
set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")