From b1708f3871565f14248fd0080cac239b6aaadc79 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 27 Sep 2016 16:56:28 +0200 Subject: [PATCH] cmake: only optimize for size on NuttX With this change only builds for NuttX which are very much flash size constraint are optimized for size. All other builds (e.g. SITL, Snapdragon, etc.) are left at the default for debugging or -O2 for the usual use. --- cmake/common/px4_base.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 871aaca5b4..db275e530f 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -675,7 +675,9 @@ function(px4_add_common_flags) if ($ENV{MEMORY_DEBUG} MATCHES "1") message(STATUS "address sanitizer enabled") - set(max_optimization -Os) + if ("${OS}" STREQUAL "nuttx") + set(max_optimization -Os) + endif() # Do not use optimization_flags (without _) as that is already used. set(_optimization_flags @@ -687,7 +689,11 @@ function(px4_add_common_flags) -g3 -fsanitize=address ) else() - set(max_optimization -Os) + if ("${OS}" STREQUAL "nuttx") + set(max_optimization -Os) + else() + set(max_optimization -O2) + endif() if ("${OS}" STREQUAL "qurt") set(PIC_FLAG -fPIC)