1 DEPENDS += " cmake-native "
3 # We need to unset CCACHE otherwise cmake gets too confused
6 # We want the staging and installing functions from autotools
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).
11 OECMAKE_SOURCEPATH ?= "."
13 # If declaring this, make sure you also set EXTRA_OEMAKE to
14 # "-C ${OECMAKE_BUILDPATH}". So it will run the right makefiles.
15 OECMAKE_BUILDPATH ?= ""
17 # C/C++ Compiler (without cpu arch/tune arguments)
18 OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
19 OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
22 OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${TARGET_CPPFLAGS}"
23 OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${TARGET_CPPFLAGS} -fpermissive"
24 OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
25 OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
27 cmake_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_SYSTEM_PROCESSOR ${TARGET_ARCH} )" >> ${WORKDIR}/toolchain.cmake
32 echo "set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )" >> ${WORKDIR}/toolchain.cmake
33 echo "set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )" >> ${WORKDIR}/toolchain.cmake
34 echo "set( CMAKE_C_FLAGS \"${OECMAKE_C_FLAGS}\" CACHE STRING \"OpenEmbedded CFLAGS\" )" >> ${WORKDIR}/toolchain.cmake
35 echo "set( CMAKE_CXX_FLAGS \"${OECMAKE_CXX_FLAGS}\" CACHE STRING \"OpenEmbedded CXXFLAGS\" )" >> ${WORKDIR}/toolchain.cmake
36 echo "set( CMAKE_C_FLAGS_RELEASE \"${OECMAKE_C_FLAGS_RELEASE}\" CACHE STRING \"CFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake
37 echo "set( CMAKE_CXX_FLAGS_RELEASE \"${OECMAKE_CXX_FLAGS_RELEASE}\" CACHE STRING \"CXXFLAGS for release\" )" >> ${WORKDIR}/toolchain.cmake
39 # only search in the paths provided (from openembedded) so cmake doesnt pick
40 # up libraries and tools from the native build machine
41 echo "set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${STAGING_DIR_NATIVE}${prefix_native}/${BASE_PACKAGE_ARCH} )" >> ${WORKDIR}/toolchain.cmake
42 echo "set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )" >> ${WORKDIR}/toolchain.cmake
43 echo "set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )" >> ${WORKDIR}/toolchain.cmake
44 echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )" >> ${WORKDIR}/toolchain.cmake
45 # Use native cmake modules
46 echo "set( CMAKE_MODULE_PATH ${STAGING_DIR_NATIVE}/usr/share/cmake-2.6/Modules/ )" >> ${WORKDIR}/toolchain.cmake
49 addtask generate_toolchain_file after do_patch before do_configure
51 cmake_do_configure() {
52 if [ ${OECMAKE_BUILDPATH} ]
54 mkdir -p ${OECMAKE_BUILDPATH}
55 cd ${OECMAKE_BUILDPATH}
58 # Just like autotools cmake can use a site file to cache result that need generated binaries to run
59 if [ -e ${WORKDIR}/site-file.cmake ] ; then
60 OECMAKE_SITEFILE=" -C ${WORKDIR}/site-file.cmake"
67 ${OECMAKE_SOURCEPATH} \
68 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
69 -DCMAKE_INSTALL_SO_NO_EXE=0 \
70 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
71 -DCMAKE_VERBOSE_MAKEFILE=1 \
77 if [ ${OECMAKE_BUILDPATH} ]
79 cd ${OECMAKE_BUILDPATH}
86 if [ ${OECMAKE_BUILDPATH} ];
88 cd ${OECMAKE_BUILDPATH}
94 EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file