From 847e13e483d1df795ef3f96d43f50bd31d92c679 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 9 Feb 2022 15:13:48 +0100 Subject: [PATCH] Set default CMAKE_BUILD_TYPE to Release before project() --- CMakeLists.txt | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a0560556..9a648dbb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2021 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2022 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause ################################################################################ @@ -11,6 +11,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "Prevented in-tree build, it is bad practice.\nTry 'cd build && cmake ..' instead.") endif() +# Select the release build type by default to get optimization flags. +# This has to come before project() which otherwise initializes it. +# Build type can still be overridden by setting -DCMAKE_BUILD_TYPE= +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") + cmake_minimum_required(VERSION 2.8.12...3.22) project(gnss-sdr CXX C) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) @@ -219,19 +224,9 @@ include(GnsssdrBuildTypes) # - O2WithASM: -O2 -g -save-temps # - O3WithASM: -O3 -g -save-temps # - ASAN: -Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer -if(NOT CMAKE_BUILD_TYPE) - if(ENABLE_GPERFTOOLS OR ENABLE_GPROF) - set(CMAKE_BUILD_TYPE "RelWithDebInfo") - message(STATUS "Build type not specified: defaulting to RelWithDebInfo.") - else() - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to Release.") - endif() -else() - message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") -endif() gnsssdr_check_build_type(${CMAKE_BUILD_TYPE}) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") +message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") + if(NOT (${CMAKE_BUILD_TYPE} STREQUAL "Release")) set(ENABLE_STRIP OFF) endif()