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-31 17:19:53 +0100
commitbe291999defd665ca2e9223f1c1dc765f72eef48 (patch)
tree4da33a835dc6e2b1ca008377208bb99463c55138
parenta0b72c297193d7cc3edb5a36bb8acbc5190537ed (diff)
downloadpoky-be291999defd665ca2e9223f1c1dc765f72eef48.tar.gz
cmake.bbclass: sync from openembedded
this fixes: - toolchain detection error (e.g. ar and ranlib) changes from openembedded: - reformatting - cmake modules search path - use 'cat <<EOF' instead of echos for clarity Signed-off-by: Qing He <qing.he@intel.com>
-rw-r--r--meta/classes/cmake.bbclass99
1 files changed, 51 insertions, 48 deletions
diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index 74e242d738..a4b0c126a2 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -25,69 +25,72 @@ OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
25OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG" 25OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
26 26
27cmake_do_generate_toolchain_file() { 27cmake_do_generate_toolchain_file() {
28 cat > ${WORKDIR}/toolchain.cmake <<EOF
28# CMake system name must be something like "Linux". 29# CMake system name must be something like "Linux".
29# This is important for cross-compiling. 30# This is important for cross-compiling.
30 echo "set( CMAKE_SYSTEM_NAME" `echo ${SDK_OS} | sed 's/^./\u&/'` ")" > ${WORKDIR}/toolchain.cmake 31set( CMAKE_SYSTEM_NAME `echo ${SDK_OS} | sed 's/^./\u&/'` )
31 echo "set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )" >> ${WORKDIR}/toolchain.cmake 32set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
32 echo "set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )" >> ${WORKDIR}/toolchain.cmake 33set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
33 echo "set( CMAKE_C_FLAGS \"${OECMAKE_C_FLAGS}\" CACHE STRING \"OpenEmbedded CFLAGS\" )" >> ${WORKDIR}/toolchain.cmake 34set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "poky CFLAGS" )
34 echo "set( CMAKE_CXX_FLAGS \"${OECMAKE_CXX_FLAGS}\" CACHE STRING \"OpenEmbedded CXXFLAGS\" )" >> ${WORKDIR}/toolchain.cmake 35set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "poky CXXFLAGS" )
35 echo "set( CMAKE_C_FLAGS_RELEASE \"${OECMAKE_C_FLAGS_RELEASE}\" CACHE STRING \"CFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake 36set( CMAKE_C_FLAGS_RELEASE "${OECMAKE_C_FLAGS_RELEASE}" CACHE STRING "CFLAGS for release" )
36 echo "set( CMAKE_CXX_FLAGS_RELEASE \"${OECMAKE_CXX_FLAGS_RELEASE}\" CACHE STRING \"CXXFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake 37set( CMAKE_CXX_FLAGS_RELEASE "${OECMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "CXXFLAGS for release" )
37 38
38# only search in the paths provided (from openembedded) so cmake doesnt pick 39# only search in the paths provided so cmake doesnt pick
39# up libraries and tools from the native build machine 40# 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 41set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} )
41 echo "set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )" >> ${WORKDIR}/toolchain.cmake 42set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
42 echo "set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )" >> ${WORKDIR}/toolchain.cmake 43set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
43 echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )" >> ${WORKDIR}/toolchain.cmake 44set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
45
44# Use native cmake modules 46# Use native cmake modules
45 echo "set( CMAKE_MODULE_PATH ${STAGING_DATADIR}/cmake/Modules/ )" >> ${WORKDIR}/toolchain.cmake 47set( CMAKE_MODULE_PATH ${STAGING_DATADIR}/cmake/Modules/ )
48EOF
46} 49}
47 50
48addtask generate_toolchain_file after do_patch before do_configure 51addtask generate_toolchain_file after do_patch before do_configure
49 52
50cmake_do_configure() { 53cmake_do_configure() {
51 if [ ${OECMAKE_BUILDPATH} ] 54 if [ ${OECMAKE_BUILDPATH} ]
52 then 55 then
53 mkdir -p ${OECMAKE_BUILDPATH} 56 mkdir -p ${OECMAKE_BUILDPATH}
54 cd ${OECMAKE_BUILDPATH} 57 cd ${OECMAKE_BUILDPATH}
55 fi 58 fi
56 59
57 # Just like autotools cmake can use a site file to cache result that need generated binaries to run 60 # 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 61 if [ -e ${WORKDIR}/site-file.cmake ] ; then
59 OECMAKE_SITEFILE=" -C ${WORKDIR}/site-file.cmake" 62 OECMAKE_SITEFILE=" -C ${WORKDIR}/site-file.cmake"
60 else 63 else
61 OECMAKE_SITEFILE="" 64 OECMAKE_SITEFILE=""
62 fi 65 fi
63 66
64 cmake \ 67 cmake \
65 ${OECMAKE_SITEFILE} \ 68 ${OECMAKE_SITEFILE} \
66 ${OECMAKE_SOURCEPATH} \ 69 ${OECMAKE_SOURCEPATH} \
67 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ 70 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
68 -DCMAKE_INSTALL_SO_NO_EXE=0 \ 71 -DCMAKE_INSTALL_SO_NO_EXE=0 \
69 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ 72 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
70 -DCMAKE_VERBOSE_MAKEFILE=1 \ 73 -DCMAKE_VERBOSE_MAKEFILE=1 \
71 ${EXTRA_OECMAKE} \ 74 ${EXTRA_OECMAKE} \
72 -Wno-dev 75 -Wno-dev
73} 76}
74 77
75cmake_do_compile() { 78cmake_do_compile() {
76 if [ ${OECMAKE_BUILDPATH} ] 79 if [ ${OECMAKE_BUILDPATH} ]
77 then 80 then
78 cd ${OECMAKE_BUILDPATH} 81 cd ${OECMAKE_BUILDPATH}
79 fi 82 fi
80 83
81 base_do_compile 84 base_do_compile
82} 85}
83 86
84cmake_do_install() { 87cmake_do_install() {
85 if [ ${OECMAKE_BUILDPATH} ]; 88 if [ ${OECMAKE_BUILDPATH} ];
86 then 89 then
87 cd ${OECMAKE_BUILDPATH} 90 cd ${OECMAKE_BUILDPATH}
88 fi 91 fi
89 92
90 autotools_do_install 93 autotools_do_install
91} 94}
92 95
93EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file 96EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file