cmake: Move some platform configuration to a toolchain file

This commit is contained in:
Florent Castelli 2016-10-11 03:27:38 +02:00
parent 9f9e11ed25
commit eb2eb4cd9b
7 changed files with 107 additions and 1845 deletions

View File

@ -54,19 +54,6 @@ if(ARM OR SIMULATOR)
set(USING_EGL ON) set(USING_EGL ON)
endif() endif()
if(EXISTS "/opt/vc/include/bcm_host.h")
message(STATUS "RaspberryPI VC Found")
set(RPI ON)
set(USING_GLES2 ON)
set(USING_FBDEV ON)
endif()
if(BB)
set(ARMV7 ON)
set(USING_FBDEV ON)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX ON) set(LINUX ON)
add_definitions(-D__STDC_CONSTANT_MACROS) add_definitions(-D__STDC_CONSTANT_MACROS)
@ -76,6 +63,10 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX ON) set(MACOSX ON)
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(ANDROID ON)
endif()
if (X86 AND NOT MIPS) if (X86 AND NOT MIPS)
if(_ARCH_64) if(_ARCH_64)
add_definitions(-D_M_X64) add_definitions(-D_M_X64)
@ -99,10 +90,6 @@ option(ARMV7 "Set to ON if targeting an ARMv7 processor" ${ARMV7})
option(ARM "Set to ON if targeting an ARM processor" ${ARM}) option(ARM "Set to ON if targeting an ARM processor" ${ARM})
option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS}) option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS})
option(X86 "Set to ON if targeting an X86 processor" ${X86}) option(X86 "Set to ON if targeting an X86 processor" ${X86})
# :: Platforms
option(ANDROID "Set to ON if targeting an Android device" ${ANDROID})
option(IOS "Set to ON if targeting an iOS device" ${IOS})
option(BB "Set to ON if targeting a Beaglebone/Beaglebone Black device" ${BB})
# :: Environments # :: Environments
option(USING_EGL "Set to ON if target environment uses EGL" ${USING_EGL}) option(USING_EGL "Set to ON if target environment uses EGL" ${USING_EGL})
option(USING_FBDEV "Set to ON if target environment uses fbdev (eg. Pandora)" ${USING_FBDEV}) option(USING_FBDEV "Set to ON if target environment uses fbdev (eg. Pandora)" ${USING_FBDEV})
@ -118,18 +105,6 @@ option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform"
option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG}) option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG}) option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
if(IOS)
if (NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/ios/ios.toolchain.cmake)
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was not set!\n"
"Delete the CMakeCache.txt file and CMakeFiles directory.\n"
"Re-run ${CMAKE_COMMAND} with:\n"
"\"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}\"")
endif()
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
endif()
if(ANDROID) if(ANDROID)
set(CoreLibName ppsspp_jni) set(CoreLibName ppsspp_jni)
set(CoreLinkType SHARED) set(CoreLinkType SHARED)
@ -142,19 +117,15 @@ endif()
include_directories(ext/native) include_directories(ext/native)
if(RPI) if(NOT OPENGL_LIBRARIES AND USING_GLES2)
include_directories(/opt/vc/include /opt/vc/include/interface/vcos/pthreads /opt/vc/include/interface/vmcs_host/linux)
link_directories(/opt/vc/lib)
set(OPENGL_LIBRARIES GLESv2 bcm_host)
elseif(USING_GLES2 AND NOT IOS)
set(OPENGL_LIBRARIES GLESv2) set(OPENGL_LIBRARIES GLESv2)
elseif(NOT IOS) endif()
if(NOT OPENGL_LIBRARIES)
include(FindOpenGL REQUIRED) include(FindOpenGL REQUIRED)
endif() endif()
if (NOT ANDROID AND NOT IOS) include(FindSDL2)
include(FindSDL2)
endif()
include(FindThreads) include(FindThreads)
if(APPLE) if(APPLE)
@ -171,13 +142,6 @@ if(MIPS)
add_definitions(-DMIPS) add_definitions(-DMIPS)
endif() endif()
if(IOS)
add_definitions(-DIOS)
endif()
if(RPI)
add_definitions(-DRPI)
endif()
if(USING_EGL) if(USING_EGL)
add_definitions(-DUSING_EGL) add_definitions(-DUSING_EGL)
endif() endif()
@ -190,9 +154,6 @@ endif()
if(MOBILE_DEVICE) if(MOBILE_DEVICE)
add_definitions(-DMOBILE_DEVICE) add_definitions(-DMOBILE_DEVICE)
endif() endif()
if(ARMV7 AND RASPBIAN)
add_definitions(-U__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2)
endif()
if (NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release") message(STATUS "No build type selected, default to Release")
@ -236,16 +197,9 @@ if(NOT MSVC)
endif() endif()
if(IOS) if(IOS)
add_definitions(-DGL_ETC1_RGB8_OES=0) elseif(APPLE AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -U__STRICT_ANSI__") # We want C++11, so target 10.7+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
# armv7s (without resorting to FastMemory) is still a work in progress
# comment out the next line to enable default/"standard" architectures (which is a fat armv7/armv7s binary)
set(CMAKE_OSX_ARCHITECTURES "armv7")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -stdlib=libc++ -U__STRICT_ANSI__") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -stdlib=libc++ -U__STRICT_ANSI__")
# Karen/angelXwind: -mmacosx-version-min=10.7 is needed in order to produce binaries that OS X 10.7 Lion can execute. However, it seems that PPSSPP won't support 10.6 or lower without getting rid of -stdlib=libc++ ...which probably won't end well. So I guess PPSSPP will strictly be a 10.7+ app.
# vit9696: OSX 10.6 builds are possible: http://forums.ppsspp.org/showthread.php?tid=1826&pid=18875#pid18875
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
else() else()
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
@ -738,23 +692,8 @@ set(nativeExtra)
set(nativeExtraLibs) set(nativeExtraLibs)
if(ARMV7) if(ARMV7)
if(BB)
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a8")
elseif(RPI)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a7 -mfpu=neon -mfloat-abi=hard")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-a7 -mfpu=neon -mfloat-abi=hard")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mcpu=cortex-a7 -mfpu=neon -mfloat-abi=hard")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
endif()
set(nativeExtra ${nativeExtra} set(nativeExtra ${nativeExtra}
ext/native/math/fast/fast_matrix_neon.S) ext/native/math/fast/fast_matrix_neon.S)
elseif(RPI)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp -march=armv6j -mfloat-abi=hard")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp -march=armv6j -mfloat-abi=hard")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mfpu=vfp -march=armv6j -mfloat-abi=hard")
endif() endif()
if(X86 AND NOT MIPS) if(X86 AND NOT MIPS)
set(nativeExtra ${nativeExtra} set(nativeExtra ${nativeExtra}
@ -786,7 +725,7 @@ elseif(IOS)
ios/iCade/iCadeReaderView.h ios/iCade/iCadeReaderView.h
ios/iCade/iCadeReaderView.m ios/iCade/iCadeReaderView.m
ios/iCade/iCadeState.h) ios/iCade/iCadeState.h)
set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit -framework GLKit -framework OpenAL") set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework GLKit -framework OpenAL")
if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework") if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework")
set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController") set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController")
endif() endif()
@ -1716,10 +1655,6 @@ endif()
file(INSTALL ${NativeAssets} DESTINATION assets) file(INSTALL ${NativeAssets} DESTINATION assets)
file(INSTALL flash0 lang DESTINATION assets) file(INSTALL flash0 lang DESTINATION assets)
if(APPLE AND NOT IOS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -F /Library/Frameworks")
endif()
# packaging and code signing # packaging and code signing
if(IOS) if(IOS)
add_dependencies(PPSSPP ${CoreLibName} GPU Common native) add_dependencies(PPSSPP ${CoreLibName} GPU Common native)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
set(ARMV7 ON)
set(USING_FBDEV ON)
set(ARCH_FLAGS "-march=armv7-a -mfpu=neon -mcpu=cortex-a8")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}")

View File

@ -0,0 +1,5 @@
set(ARMV7 ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")

View File

@ -27,16 +27,32 @@
# A macro used to find executable programs on the host system, not within the iOS environment. # A macro used to find executable programs on the host system, not within the iOS environment.
# Thanks to the android-cmake project for providing the command # Thanks to the android-cmake project for providing the command
# PPSSPP platform flags
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
set(IPHONEOS_DEPLOYMENT_TARGET 8.0)
add_definitions(
-DIOS
-DGL_ETC1_RGB8_OES=0
-U__STRICT_ANSI__
)
set(OPENGL_LIBRARIES "-framework OpenGLES")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}")
set(CMAKE_OSX_ARCHITECTURES "armv7")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
# Standard settings # Standard settings
set (CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_NAME Darwin)
set (CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_VERSION 1)
set (CMAKE_SYSTEM_PROCESSOR armv7) set(CMAKE_SYSTEM_PROCESSOR armv7)
set (UNIX True) set(UNIX ON)
set (APPLE True) set(APPLE ON)
set (IOS True) set(IOS ON)
set (APP_TYPE MACOSX_BUNDLE) set(APP_TYPE MACOSX_BUNDLE)
set (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 5.0) set(CMAKE_CROSSCOMPILING ON)
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${IPHONEOS_DEPLOYMENT_TARGET})
# Determine the cmake host system version so we know where to find the iOS SDKs # Determine the cmake host system version so we know where to find the iOS SDKs
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin) find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
@ -45,18 +61,6 @@ if (CMAKE_UNAME)
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
endif (CMAKE_UNAME) endif (CMAKE_UNAME)
# Force the compilers to clang for iOS
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (gcc gcc)
CMAKE_FORCE_CXX_COMPILER (g++ g++)
CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple)
CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple)
# Skip the platform compiler checks for cross compiling
set (CMAKE_CROSSCOMPILING TRUE)
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
# All iOS/Darwin specific settings - some may be redundant # All iOS/Darwin specific settings - some may be redundant
set (CMAKE_SHARED_LIBRARY_PREFIX "lib") set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
@ -138,11 +142,13 @@ set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS su
# set the architecture for iOS # set the architecture for iOS
# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually # NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually
if (${IOS_PLATFORM} STREQUAL "OS") if (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_ARCH armv7 armv7s) set (IOS_ARCH armv7)
endif (${IOS_PLATFORM} STREQUAL "OS") endif (${IOS_PLATFORM} STREQUAL "OS")
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS") set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}")
# Set the find root to the iOS developer roots and to user defined paths # Set the find root to the iOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root") set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
@ -157,7 +163,7 @@ set (CMAKE_SYSTEM_FRAMEWORK_PATH
) )
# only search the iOS sdks, not the remainder of the host filesystem # only search the iOS sdks, not the remainder of the host filesystem
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) #set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -0,0 +1,27 @@
if(NOT EXISTS "/opt/vc/include/bcm_host.h")
message(FATAL_ERROR "RaspberryPI platform not recognized")
endif()
include_directories(SYSTEM
/opt/vc/include
/opt/vc/include/interface/vcos/pthreads
/opt/vc/include/interface/vmcx_host/linux
)
link_directories(
/opt/vc/lib
)
add_definitions(
-DRPI
)
set(ARCH_FLAGS "-mfpu=vfp -march=armv6j -mfloat-abi=hard")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_FLAGS}")
set(OPENGL_LIBRARIES GLESv2 bcm_host)
set(USING_GLES2 ON)
set(USING_FBDEV ON)

View File

@ -0,0 +1,28 @@
if(NOT EXISTS "/opt/vc/include/bcm_host.h")
message(FATAL_ERROR "RaspberryPI platform not recognized")
endif()
include_directories(SYSTEM
/opt/vc/include
/opt/vc/include/interface/vcos/pthreads
/opt/vc/include/interface/vmcx_host/linux
)
link_directories(
/opt/vc/lib
)
add_definitions(
-DRPI
-U__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
)
set(ARCH_FLAGS "-mcpu=cortex-a7 -mfpu=neon -mfloat-abi=hard")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_FLAGS}")
set(OPENGL_LIBRARIES GLESv2 bcm_host)
set(USING_GLES2 ON)
set(USING_FBDEV ON)
set(ARMV7 ON)