|
| 1 | +# ------------------------------------------------------------------------------ |
| 2 | +# BlackBerry CMake toolchain file, for use with the BlackBerry 10 NDK |
| 3 | +# Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended). |
| 4 | +# |
| 5 | +# Usage Linux: |
| 6 | +# $ source /absolute/path/to/the/bbndk/bbndk-env.sh |
| 7 | +# $ mkdir build |
| 8 | +# $ cd build |
| 9 | +# $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/blackberry.toolchain.cmake" -DTargetPlatform="BlackBerry" -DBLACKBERRY_ARCHITECTURE=arm -DOGRE_DEPENDENCIES_DIR="../BlackBerryDependencies" -DOGRE_BUILD_RENDERSYSTEM_GLES2=TRUE -DOGRE_STATIC=TRUE -DOGRE_BUILD_COMPONENT_PAGING=TRUE -DOGRE_BUILD_COMPONENT_TERRAIN=TRUE -DOGRE_BUILD_COMPONENT_RTSHADERSYSTEM=TRUE -DOGRE_BUILD_PLUGIN_BSP=FALSE -DOGRE_BUILD_PLUGIN_PCZ=FALSE -DOGRE_BUILD_RENDERSYSTEM_GLES=FALSE -DOGRE_BUILD_TESTS=FALSE -DOGRE_BUILD_TOOLS=FALSE -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" |
| 10 | +# $ make -j8 |
| 11 | +# |
| 12 | +# Usage Mac: |
| 13 | +# Same as the steps on Linux |
| 14 | +# |
| 15 | +# Usage Windows: |
| 16 | +# > /absolute/path/to/the/bbndk/bbndk-env.bat |
| 17 | +# > mkdir build |
| 18 | +# > cd build |
| 19 | +# > cmake .. -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/blackberry.toolchain.cmake" -DTargetPlatform="BlackBerry" -DBLACKBERRY_ARCHITECTURE=arm -DOGRE_DEPENDENCIES_DIR="../BlackBerryDependencies" -DOGRE_BUILD_RENDERSYSTEM_GLES2=TRUE -DOGRE_STATIC=TRUE -DOGRE_BUILD_COMPONENT_PAGING=TRUE -DOGRE_BUILD_COMPONENT_TERRAIN=TRUE -DOGRE_BUILD_COMPONENT_RTSHADERSYSTEM=TRUE -DOGRE_BUILD_PLUGIN_BSP=FALSE -DOGRE_BUILD_PLUGIN_PCZ=FALSE -DOGRE_BUILD_RENDERSYSTEM_GLES=FALSE -DOGRE_BUILD_TESTS=FALSE -DOGRE_BUILD_TOOLS=FALSE -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" |
| 20 | +# > make -j8 |
| 21 | +# |
| 22 | + |
| 23 | +cmake_minimum_required( VERSION 2.6.3 ) |
| 24 | + |
| 25 | +if( DEFINED CMAKE_CROSSCOMPILING ) |
| 26 | + # Subsequent toolchain loading is not really needed |
| 27 | + return() |
| 28 | +endif() |
| 29 | + |
| 30 | +set( BLACKBERRY_TOOLCHAIN_ROOT "$ENV{QNX_HOST}" ) |
| 31 | +set( BLACKBERRY_TARGET_ROOT "$ENV{QNX_TARGET}" ) |
| 32 | +set( CMAKE_SYSTEM_NAME Linux ) |
| 33 | +set( CMAKE_SYSTEM_VERSION 1 ) |
| 34 | + |
| 35 | +# STL version: by default gnustl_static will be used |
| 36 | +set( BLACKBERRY_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static") |
| 37 | +mark_as_advanced( BLACKBERRY_USE_STLPORT ) |
| 38 | + |
| 39 | +# Detect host platform |
| 40 | +set( TOOL_OS_SUFFIX "" ) |
| 41 | +if( CMAKE_HOST_APPLE ) |
| 42 | + set( BLACKBERRY_NDK_HOST_SYSTEM_NAME "darwin-x86" ) |
| 43 | +elseif( CMAKE_HOST_WIN32 ) |
| 44 | + set( BLACKBERRY_NDK_HOST_SYSTEM_NAME "windows" ) |
| 45 | + set( TOOL_OS_SUFFIX ".exe" ) |
| 46 | +elseif( CMAKE_HOST_UNIX ) |
| 47 | + set(BLACKBERRY_NDK_HOST_SYSTEM_NAME "linux-x86" ) |
| 48 | +else() |
| 49 | + message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) |
| 50 | +endif() |
| 51 | + |
| 52 | +# Specify the cross compiler |
| 53 | +set( CMAKE_C_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "gcc" ) |
| 54 | +set( CMAKE_CXX_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "g++" ) |
| 55 | +set( CMAKE_ASM_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "Assembler" ) |
| 56 | +if( CMAKE_VERSION VERSION_LESS 2.8.5 ) |
| 57 | + set( CMAKE_ASM_COMPILER_ARG1 "-c" ) |
| 58 | +endif() |
| 59 | + |
| 60 | +# There may be a way to make cmake reduce these TODO |
| 61 | +if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" ) |
| 62 | + set( NEUTRINO_ARCH "v7" ) |
| 63 | +else() |
| 64 | + set( NEUTRINO_ARCH "" ) |
| 65 | +endif() |
| 66 | +set( CMAKE_STRIP "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) |
| 67 | +set( CMAKE_AR "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) |
| 68 | +set( CMAKE_LINKER "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) |
| 69 | +set( CMAKE_NM "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) |
| 70 | +set( CMAKE_OBJCOPY "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) |
| 71 | +set( CMAKE_OBJDUMP "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" ) |
| 72 | +set( CMAKE_RANLIB "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" ) |
| 73 | + |
| 74 | +# Installer |
| 75 | +#if( APPLE ) |
| 76 | +# find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool ) |
| 77 | +# if( NOT CMAKE_INSTALL_NAME_TOOL ) |
| 78 | +# message( FATAL_ERROR "Could not find install_name_tool, please check your #installation." ) |
| 79 | +# endif() |
| 80 | +# mark_as_advanced( CMAKE_INSTALL_NAME_TOOL ) |
| 81 | +# endif() |
| 82 | + |
| 83 | +# Setup output directories |
| 84 | +set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" ) |
| 85 | +set( CMAKE_INSTALL_PREFIX "${BLACKBERRY_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) |
| 86 | + |
| 87 | +if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) |
| 88 | + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) |
| 89 | +else() |
| 90 | + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) |
| 91 | +endif() |
| 92 | + |
| 93 | +# Includes |
| 94 | +list( APPEND BLACKBERRY_SYSTEM_INCLUDE_DIRS "${BLACKBERRY_TARGET_ROOT}/qnx6/usr/include" ) |
| 95 | + |
| 96 | +# Flags and preprocessor definitions |
| 97 | +if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" ) |
| 98 | + set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntoarmv7le -D__QNX__" ) |
| 99 | + set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntoarmv7le -Y_gpp -D__QNX__" ) |
| 100 | +else() |
| 101 | + set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntox86 -D__QNX__" ) |
| 102 | + set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntox86 -Y_gpp -D__QNX__" ) |
| 103 | +endif() |
| 104 | +set( BLACKBERRY 1 ) |
| 105 | + |
| 106 | +# NDK flags |
| 107 | +set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" ) |
| 108 | +set( CMAKE_C_FLAGS "${BLACKBERRY_CC_FLAGS}" ) |
| 109 | +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" ) |
| 110 | +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" ) |
| 111 | + |
| 112 | +# Release and Debug flags |
| 113 | +if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" ) |
| 114 | + set( CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" ) |
| 115 | + set( CMAKE_C_FLAGS_RELEASE "-mthumb -O3" ) |
| 116 | + set( CMAKE_CXX_FLAGS_DEBUG "-g -marm -Os -finline-limit=64" ) |
| 117 | + set( CMAKE_C_FLAGS_DEBUG "-g -marm -Os -finline-limit=64" ) |
| 118 | +else() |
| 119 | + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i486" ) |
| 120 | + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i486" ) |
| 121 | +endif() |
| 122 | + |
| 123 | +# Cache flags |
| 124 | +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" ) |
| 125 | +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags" ) |
| 126 | +set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" ) |
| 127 | +set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" ) |
| 128 | +set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" ) |
| 129 | +set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" ) |
| 130 | +set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" ) |
| 131 | +SET( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" CACHE STRING "linker flags") |
| 132 | +SET( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" CACHE STRING "linker flags") |
| 133 | +set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" ) |
| 134 | +set( CMAKE_EXE_LINKER_FLAGS "-lstdc++ -lm -lEGL -lGLESv2 -lbps -lscreen" CACHE STRING "linker flags" ) |
| 135 | + |
| 136 | +# Finish flags |
| 137 | +set( BLACKBERRY_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" CACHE INTERNAL "Extra BlackBerry compiler flags") |
| 138 | +set( BLACKBERRY_LINKER_FLAGS "${BLACKBERRY_LINKER_FLAGS}" CACHE INTERNAL "Extra BlackBerry linker flags") |
| 139 | +set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" ) |
| 140 | +set( CMAKE_C_FLAGS "${BLACKBERRY_CXX_FLAGS} ${CMAKE_C_FLAGS}" ) |
| 141 | + |
| 142 | +# Global flags for cmake client scripts to change behavior |
| 143 | +set( BLACKBERRY True ) |
| 144 | +# Find the Target environment |
| 145 | +set( CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}" "${BLACKBERRY_TARGET_ROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) |
| 146 | +# Search for libraries and includes in the ndk toolchain |
| 147 | +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) |
| 148 | +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) |
| 149 | +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) |
| 150 | + |
| 151 | +# Macro to find packages on the host OS |
| 152 | +macro( find_host_package ) |
| 153 | + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) |
| 154 | + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) |
| 155 | + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) |
| 156 | + if( CMAKE_HOST_WIN32 ) |
| 157 | + SET( WIN32 1 ) |
| 158 | + SET( UNIX ) |
| 159 | + elseif( CMAKE_HOST_APPLE ) |
| 160 | + SET( APPLE 1 ) |
| 161 | + SET( UNIX ) |
| 162 | + endif() |
| 163 | + find_package( ${ARGN} ) |
| 164 | + SET( WIN32 ) |
| 165 | + SET( APPLE ) |
| 166 | + SET( UNIX 1 ) |
| 167 | + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) |
| 168 | + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) |
| 169 | + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) |
| 170 | +endmacro() |
| 171 | + |
| 172 | +# Macro to find programs on the host OS |
| 173 | +macro( find_host_program ) |
| 174 | + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) |
| 175 | + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) |
| 176 | + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) |
| 177 | + if( CMAKE_HOST_WIN32 ) |
| 178 | + SET( WIN32 1 ) |
| 179 | + SET( UNIX ) |
| 180 | + elseif( CMAKE_HOST_APPLE ) |
| 181 | + SET( APPLE 1 ) |
| 182 | + SET( UNIX ) |
| 183 | + endif() |
| 184 | + find_program( ${ARGN} ) |
| 185 | + SET( WIN32 ) |
| 186 | + SET( APPLE ) |
| 187 | + SET( UNIX 1 ) |
| 188 | + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) |
| 189 | + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) |
| 190 | + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) |
| 191 | +endmacro() |
| 192 | + |
| 193 | +# We are doing cross compiling, reset the OS information of the Building system |
| 194 | +UNSET( APPLE ) |
| 195 | +UNSET( WIN32 ) |
| 196 | +UNSET( UNIX ) |
0 commit comments