From 982b86fa48de74a58dc10e1ecb3ecbfd42e735cf Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sun, 25 Nov 2018 14:25:23 +0100 Subject: [PATCH] CMake: Add support for Debug/Release builds --- contrib/ports/CMakeCommon.cmake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/ports/CMakeCommon.cmake b/contrib/ports/CMakeCommon.cmake index 72deb376..5cf65bdb 100644 --- a/contrib/ports/CMakeCommon.cmake +++ b/contrib/ports/CMakeCommon.cmake @@ -2,6 +2,12 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") include_guard(GLOBAL) endif() +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "CMAKE_BUILD_TYPE not set - defaulting to Debug build.") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE) +endif() +message (STATUS "Build type: ${CMAKE_BUILD_TYPE}") + set(LWIP_CONTRIB_DIR ${LWIP_DIR}/contrib) # ARM mbedtls support https://tls.mbed.org/ @@ -33,6 +39,8 @@ if(EXISTS ${LWIP_MBEDTLSDIR}/CMakeLists.txt) endif() set(LWIP_COMPILER_FLAGS_GNU_CLANG + $<$:-Og> + $<$:-O3> -g -Wall -pedantic @@ -111,5 +119,10 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") endif() if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - set(LWIP_COMPILER_FLAGS /Wall /WX) + set(LWIP_COMPILER_FLAGS + $<$:/O0> + $<$:/O2> + /Wall + /WX + ) endif()