vita.toolchain.cmake (5966B)
1 # Copyright (c) 2016, Yifan Lu 2 # Based off of Android toolchain file 3 # Copyright (c) 2010-2011, Ethan Rublee 4 # Copyright (c) 2011-2014, Andrey Kamaev 5 # All rights reserved. 6 # 7 # Redistribution and use in source and binary forms, with or without 8 # modification, are permitted provided that the following conditions are met: 9 # 10 # 1. Redistributions of source code must retain the above copyright notice, 11 # this list of conditions and the following disclaimer. 12 # 13 # 2. Redistributions in binary form must reproduce the above copyright notice, 14 # this list of conditions and the following disclaimer in the documentation 15 # and/or other materials provided with the distribution. 16 # 17 # 3. Neither the name of the copyright holder nor the names of its 18 # contributors may be used to endorse or promote products derived from this 19 # software without specific prior written permission. 20 # 21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 # POSSIBILITY OF SUCH DAMAGE. 32 33 cmake_minimum_required( VERSION 2.6.3 ) 34 35 if( DEFINED CMAKE_CROSSCOMPILING ) 36 # subsequent toolchain loading is not really needed 37 return() 38 endif() 39 40 if( CMAKE_TOOLCHAIN_FILE ) 41 # touch toolchain variable to suppress "unused variable" warning 42 endif() 43 44 set( CMAKE_SYSTEM_NAME Generic ) 45 set( CMAKE_SYSTEM_VERSION 1 ) 46 47 # search for Vita SDK path 1) where this toolchain file is, 2) in environment var, 3) manually defined 48 if( NOT DEFINED ENV{VITASDK} ) 49 get_filename_component(__vitasdk_path ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) 50 if( EXISTS "${__vitasdk_path}" ) 51 set( VITASDK "${__vitasdk_path}" ) 52 set( ENV{VITASDK} "${__vitasdk_path}" ) 53 endif() 54 else() 55 set( VITASDK "$ENV{VITASDK}" ) 56 endif() 57 set( VITASDK "${VITASDK}" CACHE PATH "Path to Vita SDK root" ) 58 59 if( NOT EXISTS "${VITASDK}" ) 60 message( FATAL_ERROR "Cannot find Vita SDK at ${VITASDK}" ) 61 endif() 62 63 set( TOOL_OS_SUFFIX "" ) 64 if( CMAKE_HOST_WIN32 ) 65 set( TOOL_OS_SUFFIX ".exe" ) 66 endif() 67 68 set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) 69 set( CMAKE_C_COMPILER "${VITASDK}/bin/arm-vita-eabi-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler" ) 70 set( CMAKE_CXX_COMPILER "${VITASDK}/bin/arm-vita-eabi-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler" ) 71 set( CMAKE_ASM_COMPILER "${VITASDK}/bin/arm-vita-eabi-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" ) 72 set( CMAKE_STRIP "${VITASDK}/bin/arm-vita-eabi-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) 73 set( CMAKE_AR "${VITASDK}/bin/arm-vita-eabi-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) 74 set( CMAKE_LINKER "${VITASDK}/bin/arm-vita-eabi-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) 75 set( CMAKE_NM "${VITASDK}/bin/arm-vita-eabi-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) 76 set( CMAKE_OBJCOPY "${VITASDK}/bin/arm-vita-eabi-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) 77 set( CMAKE_OBJDUMP "${VITASDK}/bin/arm-vita-eabi-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" ) 78 set( CMAKE_RANLIB "${VITASDK}/bin/arm-vita-eabi-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" ) 79 80 # Vita specific tools 81 set( VITA_ELF_CREATE "${VITASDK}/bin/vita-elf-create${TOOL_OS_SUFFIX}" CACHE PATH "vita-elf-create" ) 82 set( VITA_ELF_EXPORT "${VITASDK}/bin/vita-elf-export${TOOL_OS_SUFFIX}" CACHE PATH "vita-elf-export" ) 83 set( VITA_LIBS_GEN "${VITASDK}/bin/vita-libs-gen${TOOL_OS_SUFFIX}" CACHE PATH "vita-libs-gen" ) 84 set( VITA_MAKE_FSELF "${VITASDK}/bin/vita-make-fself${TOOL_OS_SUFFIX}" CACHE PATH "vita-make-fself" ) 85 set( VITA_MKSFOEX "${VITASDK}/bin/vita-mksfoex${TOOL_OS_SUFFIX}" CACHE PATH "vita-mksfoex" ) 86 set( VITA_PACK_VPK "${VITASDK}/bin/vita-pack-vpk${TOOL_OS_SUFFIX}" CACHE PATH "vita-pack-vpk" ) 87 88 # cache flags 89 set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" ) 90 set( CMAKE_C_FLAGS "" CACHE STRING "c flags" ) 91 set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags" ) 92 set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags" ) 93 set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" ) 94 set( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" ) 95 set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" ) 96 set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" ) 97 set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" ) 98 99 # we require the relocation table 100 set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q" ) 101 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-q" ) 102 103 # set these global flags for cmake client scripts to change behavior 104 set( VITA True ) 105 set( BUILD_VITA True ) 106 107 # where is the target environment 108 set( CMAKE_FIND_ROOT_PATH "${VITASDK}/bin" "${VITASDK}/arm-vita-eabi" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) 109 set( CMAKE_INSTALL_PREFIX "${VITASDK}/arm-vita-eabi" CACHE PATH "default install path" ) 110 111 # only search for libraries and includes in vita toolchain 112 if( NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ) 113 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 114 endif() 115 if( NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ) 116 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 117 endif()