summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQing He <qing.he@intel.com>2010-08-20 10:57:48 +0800
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-27 13:29:49 +0100
commit5bb55610f3eb6bba0c04d57733ffa056705c5336 (patch)
treebbad52327b9db8e79e63ebcf1a5bb69c6e0164ca
parent6bfeb80d57897547057b3ffbbc3c6f3c16c2d473 (diff)
downloadpoky-5bb55610f3eb6bba0c04d57733ffa056705c5336.tar.gz
cmake.bbclass: sync from openembedded
this fixes: - toolchain detection error (e.g. ar and ranlib) - cmake modules search path Signed-off-by: Qing He <qing.he@intel.com>
-rw-r--r--meta/classes/cmake.bbclass91
1 files changed, 84 insertions, 7 deletions
diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index 6adc43f057..74e242d738 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -1,16 +1,93 @@
1DEPENDS += " cmake-native " 1DEPENDS += " cmake-native "
2 2
3# We need to unset CCACHE otherwise cmake gets too confused
4CCACHE = ""
5
3# We want the staging and installing functions from autotools 6# We want the staging and installing functions from autotools
4inherit autotools 7inherit autotools
5 8
6EXTRA_OECMAKE ?= "" 9# Use in-tree builds by default but allow this to be changed
10# since some packages do not support them (e.g. llvm 2.5).
11OECMAKE_SOURCEPATH ?= "."
12
13# If declaring this, make sure you also set EXTRA_OEMAKE to
14# "-C ${OECMAKE_BUILDPATH}". So it will run the right makefiles.
15OECMAKE_BUILDPATH ?= ""
16
17# C/C++ Compiler (without cpu arch/tune arguments)
18OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
19OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
20
21# Compiler flags
22OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${TARGET_CPPFLAGS}"
23OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${TARGET_CPPFLAGS} -fpermissive"
24OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
25OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
26
27cmake_do_generate_toolchain_file() {
28# CMake system name must be something like "Linux".
29# This is important for cross-compiling.
30 echo "set( CMAKE_SYSTEM_NAME" `echo ${SDK_OS} | sed 's/^./\u&/'` ")" > ${WORKDIR}/toolchain.cmake
31 echo "set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )" >> ${WORKDIR}/toolchain.cmake
32 echo "set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )" >> ${WORKDIR}/toolchain.cmake
33 echo "set( CMAKE_C_FLAGS \"${OECMAKE_C_FLAGS}\" CACHE STRING \"OpenEmbedded CFLAGS\" )" >> ${WORKDIR}/toolchain.cmake
34 echo "set( CMAKE_CXX_FLAGS \"${OECMAKE_CXX_FLAGS}\" CACHE STRING \"OpenEmbedded CXXFLAGS\" )" >> ${WORKDIR}/toolchain.cmake
35 echo "set( CMAKE_C_FLAGS_RELEASE \"${OECMAKE_C_FLAGS_RELEASE}\" CACHE STRING \"CFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake
36 echo "set( CMAKE_CXX_FLAGS_RELEASE \"${OECMAKE_CXX_FLAGS_RELEASE}\" CACHE STRING \"CXXFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake
37
38# only search in the paths provided (from openembedded) so cmake doesnt pick
39# up libraries and tools from the native build machine
40 echo "set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} )" >> ${WORKDIR}/toolchain.cmake
41 echo "set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )" >> ${WORKDIR}/toolchain.cmake
42 echo "set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )" >> ${WORKDIR}/toolchain.cmake
43 echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )" >> ${WORKDIR}/toolchain.cmake
44# Use native cmake modules
45 echo "set( CMAKE_MODULE_PATH ${STAGING_DATADIR}/cmake/Modules/ )" >> ${WORKDIR}/toolchain.cmake
46}
47
48addtask generate_toolchain_file after do_patch before do_configure
7 49
8cmake_do_configure() { 50cmake_do_configure() {
9 cmake . -DCMAKE_INSTALL_PREFIX:PATH=${prefix} -Wno-dev \ 51 if [ ${OECMAKE_BUILDPATH} ]
10 -DCMAKE_FIND_ROOT_PATH=${STAGING_DIR_HOST} \ 52 then
11 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ 53 mkdir -p ${OECMAKE_BUILDPATH}
12 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ 54 cd ${OECMAKE_BUILDPATH}
13 ${EXTRA_OECMAKE} 55 fi
56
57 # Just like autotools cmake can use a site file to cache result that need generated binaries to run
58 if [ -e ${WORKDIR}/site-file.cmake ] ; then
59 OECMAKE_SITEFILE=" -C ${WORKDIR}/site-file.cmake"
60 else
61 OECMAKE_SITEFILE=""
62 fi
63
64 cmake \
65 ${OECMAKE_SITEFILE} \
66 ${OECMAKE_SOURCEPATH} \
67 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
68 -DCMAKE_INSTALL_SO_NO_EXE=0 \
69 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
70 -DCMAKE_VERBOSE_MAKEFILE=1 \
71 ${EXTRA_OECMAKE} \
72 -Wno-dev
73}
74
75cmake_do_compile() {
76 if [ ${OECMAKE_BUILDPATH} ]
77 then
78 cd ${OECMAKE_BUILDPATH}
79 fi
80
81 base_do_compile
82}
83
84cmake_do_install() {
85 if [ ${OECMAKE_BUILDPATH} ];
86 then
87 cd ${OECMAKE_BUILDPATH}
88 fi
89
90 autotools_do_install
14} 91}
15 92
16EXPORT_FUNCTIONS do_configure 93EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file