From 8531eed15872fbeb4db455d3eadff5fdb8a19ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ku=C5=BAnia?= Date: Thu, 18 Mar 2021 02:00:06 +0100 Subject: [PATCH] [cmake] do not set CMAKE_BUILD_TYPE if OT is not a top-level project (#6289) --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 548dc8c8e..6a9a5d3f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,9 +58,16 @@ include("${PROJECT_SOURCE_DIR}/etc/cmake/options.cmake") include("${PROJECT_SOURCE_DIR}/etc/cmake/functions.cmake") if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "default build type: Debug" FORCE) + # Check if this is a top-level CMake. + # If it is not, do not set the CMAKE_BUILD_TYPE because OpenThread is a part of something bigger. + if ("${CMAKE_PROJECT_NAME}" STREQUAL "openthread") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "default build type: Debug" FORCE) + endif () endif() -message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}") + +if (CMAKE_BUILD_TYPE) + message(STATUS "OpenThread CMake build type: ${CMAKE_BUILD_TYPE}") +endif () if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang") option(OT_COMPILE_WARNING_AS_ERROR "whether to include -Werror -pedantic-errors with gcc-compatible compilers")