[oe-commits] [openembedded-core] 06/14: cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1

git at git.openembedded.org git at git.openembedded.org
Mon Jun 24 16:35:25 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 23fbce72035673b6c7b72107e97dbc955e3b05ac
Author: Nikolai Merinov <n.merinov at inango-systems.com>
AuthorDate: Thu Jun 20 14:15:14 2019 +0500

    cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1
    
    The CMake takes mandatory compiler arguments from the following variables:
    - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler.
    - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers
      that supports several targets through command line options.
      e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}".
    - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain,
      used for compilers that support build with external toolchain.
      e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}".
    - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler
      command.
    
    CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory
    arguments, that belongs to CC variable with other build systems, to a
    compiler.
    
    Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of
    CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by
    CMakeLists.txt files.
    
    Signed-off-by: Nikolai Merinov <n.merinov at inango-systems.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/cmake.bbclass | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index 2b317c8..8355c8e 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -28,26 +28,34 @@ python() {
         if cc_list[0] == 'ccache':
             d.setVar('OECMAKE_C_COMPILER_LAUNCHER', cc_list[0])
             d.setVar('OECMAKE_C_COMPILER', cc_list[1])
+            cc_arg1 = ' '.join(cc_list[2:])
         else:
             d.setVar('OECMAKE_C_COMPILER', cc_list[0])
+            cc_arg1 = ' '.join(cc_list[1:])
+        if not d.getVar('OECMAKE_C_COMPILER_ARG1'):
+            d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1)
 
     if not d.getVar('OECMAKE_CXX_COMPILER'):
         cxx_list = d.getVar('CXX').split()
         if cxx_list[0] == 'ccache':
             d.setVar('OECMAKE_CXX_COMPILER_LAUNCHER', cxx_list[0])
             d.setVar('OECMAKE_CXX_COMPILER', cxx_list[1])
+            cxx_arg1 = ' '.join(cxx_list[2:])
         else:
             d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0])
+            cxx_arg1 = ' '.join(cxx_list[1:])
+        if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'):
+            d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1)
 }
 OECMAKE_AR ?= "${AR}"
 
 # Compiler flags
-OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}"
-OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}"
+OECMAKE_C_FLAGS ?= "${CFLAGS}"
+OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}"
 OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG"
 OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG"
-OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}"
-OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}"
+OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}"
+OECMAKE_CXX_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}"
 CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
 CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
 
@@ -90,10 +98,13 @@ $cmake_crosscompiling
 set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` )
 set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} )
 set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
+set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" )
 set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
+set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" )
 set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} )
 set( CMAKE_CXX_COMPILER_LAUNCHER ${OECMAKE_CXX_COMPILER_LAUNCHER} )
 set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} )
+set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" )
 set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" )
 set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" )
 set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" )

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list