From patchwork Sat Oct 15 21:03:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Martin X-Patchwork-Id: 682618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sxH6F6QL8z9s9c for ; Sun, 16 Oct 2016 08:04:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=l2Ak3rVL; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7D200C2672; Sat, 15 Oct 2016 21:04:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H3ebmvF0iFJV; Sat, 15 Oct 2016 21:04:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 78E74C2554; Sat, 15 Oct 2016 21:04:42 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id D5CFB1C16AB for ; Sat, 15 Oct 2016 21:04:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D20148ABC1 for ; Sat, 15 Oct 2016 21:04:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u9RHEdZs8U30 for ; Sat, 15 Oct 2016 21:04:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id EF2768ABB4 for ; Sat, 15 Oct 2016 21:04:30 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id b80so3766842wme.2 for ; Sat, 15 Oct 2016 14:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W7Zzmj94gUMqwrqDhmN9FB92xBnEfl907cU9ehUlsQk=; b=l2Ak3rVLjzrjbP5opTc1/wFTXiZkS8bBxAkTqBXtf3KmVuDHbG2ye/GkZjJoJ3BCEU DurNKYdpugM7VCwaE69wWkPPdm6J24XI3tqtcSQ+9E6oJuauXIls5J/m1vSSDtDMVKOJ LGRceoSZyh/u3Wu1WcIFUFPyZo1+D6UF9LfTM/EHACzK/WjjagzBuiOpdNR4H4RvTiKh nE5oF+IXxRxRq5evQpnlNRa+Z+AT3oOTdnxug8n+BekGpMor/7/QfGRtAcxX1W9wkKP7 bdF+TlJstvCuoRWkZ7Z99je1WrgfZEX0tiQoqmNjjuDOuoQFTOvqPac31/MmdIjhFrYs 9eSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W7Zzmj94gUMqwrqDhmN9FB92xBnEfl907cU9ehUlsQk=; b=QNVhvSwfC83WWSSuago/ltJO6JohrPpKI3LztpR1egKVyy3jvq8K6lHTADh0oK8wVP Lzmt/baYHv8ZPJgdeclJC5S+ELd/N5j6SOj4AvYWw5GKqexpS+eb1c8lXC6mGsevJTgs LzxtvTWGcpdS/3I5PEY/2VO4JN6ajj8HwO2LbRc1NxJK2mgOg1sVDfWWNNNlSrfVg96N OCvTqAog2p2tJFdOtSkt/FddUC1J7z+ksFPdtj3Vn8IcGWY4c0lhOtiX5DMeDYtQhP3V yG8uQP8dtxDbU6gfso08In85M/2M84tXiKPCZ7YIv2FQTiS+YjfU0EHqHet77/rfSYgs EHMQ== X-Gm-Message-State: AA6/9Rkvza5crlRcoctwzdEl7ejCcAPI41lGVkG8fZZOgFBko0wCZF55R0W8c9erxbXjXg== X-Received: by 10.194.85.106 with SMTP id g10mr6479273wjz.128.1476565469197; Sat, 15 Oct 2016 14:04:29 -0700 (PDT) Received: from localhost.localdomain (p5DC47BBB.dip0.t-ipconnect.de. [93.196.123.187]) by smtp.gmail.com with ESMTPSA id m6sm5103756wmi.23.2016.10.15.14.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Oct 2016 14:04:28 -0700 (PDT) From: Samuel Martin To: buildroot@buildroot.org Date: Sat, 15 Oct 2016 23:03:49 +0200 Message-Id: <20161015210349.29432-10-s.martin49@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161015210349.29432-1-s.martin49@gmail.com> References: <20161015210349.29432-1-s.martin49@gmail.com> Cc: Thomas Petazzoni Subject: [Buildroot] [PATCH v5 9/9] toochainfile.cmake: rework the way Buildroot sets flags X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From the build configuration, Buildroot defines and set some compiler and linker flags that should be passed to any packages build-system. For package using the cmake-package infrastructure, this is achieved via the toolchainfile.cmake. This change simplifies the way the toolchainfile.cmake file handles these flags: it now just sets them, without any attempt to extend them with those Buildroot defined. This change still allows overriding these flags from the configure command line. So, now, when a CMake-based package needs to extend them, they should be fully set from the package *.mk file. This behavior is consistent with what is done for others package infrastructures. This change should not pull any regression WRT the bug #7280 [1]. However, now, when someone uses the toolchainfile.cmake file outside of Buildroot, he/she must overload all compiler/linker flags (including the ones Buildroot sets since they no longer get automatically added). [1] https://bugs.busybox.net/show_bug.cgi?id=7280 Cc: Arnout Vandecappelle (Essensium/Mind) Cc: Max Filippov Cc: Thomas Petazzoni Signed-off-by: Samuel Martin --- changes v4->v5: - fix cmake set call changes v3->v4: - add a note about what the CMake code should look like (Arnout) - fix overriding support (add missing CACHE keyword) - update CHANGES text --- CHANGES | 5 ++++- support/misc/toolchainfile.cmake.in | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index c0e3e79..3657710 100644 --- a/CHANGES +++ b/CHANGES @@ -2,7 +2,10 @@ toolchainfile.cmake: * when used outside of Buildroot, if not specified on the command - line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake. + line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake; + * when used outside of Buildroot with custom compiler/linker + flags, the Buildroot flags should be set along side with the + custom ones. 2016.08, Released September 1st, 2016 diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in index 75f3fb2..3e1a056 100644 --- a/support/misc/toolchainfile.cmake.in +++ b/support/misc/toolchainfile.cmake.in @@ -28,9 +28,17 @@ set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS") # Build type from the Buildroot configuration set(CMAKE_BUILD_TYPE @@BR_CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration") -set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS") -set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS") -set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS") +# Buildroot defaults flags. +# If you are using this toolchainfile.cmake file outside of Buildroot and +# want to customize the compiler/linker flags, then: +# * set them all on the cmake command line, e.g.: +# cmake -DCMAKE_C_FLAGS="@@TARGET_CFLAGS@@ -Dsome_custom_flag" ... +# * and make sure the project's CMake code extendsthem like this if needed: +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dsome_definitions") +set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@" CACHE STRING "Buildroot CFLAGS") +set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@" CACHE STRING "Buildroot CXXFLAGS") +set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for executables") + set(CMAKE_INSTALL_SO_NO_EXE 0) set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin") @@ -46,6 +54,7 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@") set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@") set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@") if(@@TOOLCHAIN_HAS_FORTRAN@@) - set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@ ${CMAKE_Fortran_FLAGS}" CACHE STRING "Buildroot FCFLAGS") + # Buildroot defaults flags. + set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@" CACHE STRING "Buildroot FCFLAGS") set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@") endif()