CMakeLists cleanup.

Tabified CMakeLists. Introduced USING_GLES2 and X86 option and exposed USING_GLES2 to C++. Removed some redundancies and messiness.
This commit is contained in:
Sacha 2012-11-26 12:41:57 +10:00
parent 1a7ca88df4
commit a1a72b3f21

View File

@ -17,20 +17,26 @@ if(BLACKBERRY)
set(ARM ON) set(ARM ON)
endif() endif()
if (ARM)
set(USING_GLES2 ON)
else() # Assume x86
set(X86 ON)
endif()
# User-editable options (go into CMakeCache.txt) # User-editable options (go into CMakeCache.txt)
option(ARM "Set to ON if targeting an ARM processor" ${ARM}) option(ARM "Set to ON if targeting an ARM processor" ${ARM})
option(ANDROID "Set to ON if targeting an Android phone" ${ANDROID}) option(X86 "Set to ON if targeting an X86 processor" ${X86})
option(BLACKBERRY "Set to ON if targeting a Blackberry phone" ${BLACKBERRY}) option(ANDROID "Set to ON if targeting an Android device" ${ANDROID})
option(BLACKBERRY "Set to ON if targeting a Blackberry device" ${BLACKBERRY})
option(USING_GLES2 "Set to ON if target device uses OpenGL ES 2.0" ${USING_GLES2})
option(HEADLESS "Set to OFF to not generate the PPSSPPHeadless target" ${HEADLESS}) option(HEADLESS "Set to OFF to not generate the PPSSPPHeadless target" ${HEADLESS})
if(ANDROID) if(ANDROID)
if(NOT ANDROID_ABI) if(NOT ANDROID_ABI)
message(FATAL_ERROR message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was not set!\n"
"CMAKE_TOOLCHAIN_FILE was not set!! "Delete the CMakeCache.txt file and CMakeFiles directory."
Delete the CMakeCache.txt file and CMakeFiles directory. "Rerun ${CMAKE_COMMAND} with \"-DCMAKE_TOOLCHAIN_FILE"
Rerun ${CMAKE_COMMAND} with the "=${CMAKE_SOURCE_DIR}/android/android.toolchain.cmake\"")
\"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/android/android.toolchain.cmake\"
argument")
endif() endif()
set(CoreLibName ppsspp_jni) set(CoreLibName ppsspp_jni)
set(CoreLinkType SHARED) set(CoreLinkType SHARED)
@ -40,19 +46,17 @@ else()
endif() endif()
#find_package(Qt5Widgets) #find_package(Qt5Widgets)
if(ANDROID OR BLACKBERRY) if(USING_GLES2)
set(OPENGL_LIBRARIES GLESv2) set(OPENGL_LIBRARIES GLESv2)
set(OPENSL_LIBRARIES OpenSLES)
else() else()
include(FindOpenGL REQUIRED) include(FindOpenGL REQUIRED)
endif() endif()
include(FindSDL) include(FindSDL)
include(FindThreads) include(FindThreads)
# needed for Globals.h # Needed for Globals.h
include_directories("${CMAKE_SOURCE_DIR}") include_directories("${CMAKE_SOURCE_DIR}")
# TODO: Rely on compiler define instead. __BLACKBERRY__ ?
if(BLACKBERRY) if(BLACKBERRY)
add_definitions(-DBLACKBERRY) add_definitions(-DBLACKBERRY)
if(BLACKBERRY VERSION_GREATER 10) if(BLACKBERRY VERSION_GREATER 10)
@ -67,8 +71,13 @@ endif()
if(ARM) if(ARM)
add_definitions(-DARM) add_definitions(-DARM)
endif() endif()
if (USING_GLES2)
add_definitions(-DUSING_GLES2)
endif()
if(NOT MSVC) if(NOT MSVC)
# Disable warnings about va_list mangling
add_definitions(-Wno-psabi)
add_definitions(-fno-strict-aliasing) add_definitions(-fno-strict-aliasing)
if(NOT APPLE) if(NOT APPLE)
add_definitions(-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1) add_definitions(-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1)
@ -79,21 +88,18 @@ if(NOT MSVC)
add_definitions(-D_QNX_SOURCE=1 -D_C99=1) add_definitions(-D_QNX_SOURCE=1 -D_C99=1)
endif() endif()
if(NOT ARM) # ASSUMES x86!! if(X86)
# enable sse2 code generation # enable sse2 code generation
add_definitions(-msse2) add_definitions(-msse2)
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX AND if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.0)
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif() endif()
endif() else()
# Disable warnings about MS-specific _s variants of libc functions
if(MSVC)
# disable warnings about MS-specific _s variants of libc functions
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif() endif()
@ -130,7 +136,7 @@ if(ARM)
Common/ArmEmitter.h Common/ArmEmitter.h
Common/ArmEmitter.cpp Common/ArmEmitter.cpp
Common/ThunkARM.cpp) Common/ThunkARM.cpp)
else() elseif(X86)
set(CommonExtra ${CommonExtra} set(CommonExtra ${CommonExtra}
Common/ABI.cpp Common/ABI.cpp
Common/ABI.h Common/ABI.h
@ -242,7 +248,7 @@ add_library(etcpack STATIC
native/ext/etcpack/image.h) native/ext/etcpack/image.h)
include_directories(native/ext/etcpack) include_directories(native/ext/etcpack)
if(NOT ANDROID AND NOT BLACKBERRY) if(NOT USING_GLES2)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
add_definitions(-DGLEW_STATIC) add_definitions(-DGLEW_STATIC)
@ -344,15 +350,14 @@ if(ANDROID)
add_library(native_audio SHARED add_library(native_audio SHARED
native/android/native-audio-so.cpp native/android/native-audio-so.cpp
native/android/native-audio-so.h) native/android/native-audio-so.h)
target_link_libraries(native_audio target_link_libraries(native_audio OpenSLES)
${OPENSL_LIBRARIES})
endif() endif()
if(BLACKBERRY) if(BLACKBERRY)
set(nativeExtra ${nativeExtra} set(nativeExtra ${nativeExtra}
native/base/BlackberryMain.cpp) native/base/BlackberryMain.cpp)
endif() endif()
if(NOT ARM) if(X86)
set(nativeExtra ${nativeExtra} set(nativeExtra ${nativeExtra}
native/base/backtrace.cpp native/base/backtrace.cpp
native/base/backtrace.h) native/base/backtrace.h)
@ -480,8 +485,7 @@ add_library(native STATIC
include_directories(native) include_directories(native)
# rapidxml is headers only so we can't make a lib specific for it # rapidxml is headers only so we can't make a lib specific for it
include_directories(native/ext/rapidxml) include_directories(native/ext/rapidxml)
target_link_libraries(native ${LIBZIP} target_link_libraries(native ${LIBZIP} etcpack sha1 stb_image stb_vorbis #vjson
etcpack sha1 stb_image stb_vorbis #vjson
zlib ${GLEW_LIBRARIES}) zlib ${GLEW_LIBRARIES})
if(ANDROID) if(ANDROID)
target_link_libraries(native log) target_link_libraries(native log)
@ -519,7 +523,7 @@ if(ARM)
Core/MIPS/ARM/JitCache.h Core/MIPS/ARM/JitCache.h
Core/MIPS/ARM/RegCache.cpp Core/MIPS/ARM/RegCache.cpp
Core/MIPS/ARM/RegCache.h) Core/MIPS/ARM/RegCache.h)
else() # ASSUMES x86!! elseif(X86)
set(CoreExtra ${CoreExtra} set(CoreExtra ${CoreExtra}
Core/MIPS/x86/Asm.cpp Core/MIPS/x86/Asm.cpp
Core/MIPS/x86/Asm.h Core/MIPS/x86/Asm.h
@ -789,10 +793,8 @@ if(WIN32)
endif() endif()
if(HEADLESS) if(HEADLESS)
add_executable(PPSSPPHeadless add_executable(PPSSPPHeadless headless/Headless.cpp)
headless/Headless.cpp) target_link_libraries(PPSSPPHeadless ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(PPSSPPHeadless ${CoreLibName}
${CMAKE_THREAD_LIBS_INIT})
setup_target_project(PPSSPPHeadless headless) setup_target_project(PPSSPPHeadless headless)
endif() endif()
@ -813,33 +815,23 @@ if(SDL_FOUND)
${SDL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) ${SDL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
if(BLACKBERRY) if(BLACKBERRY)
add_executable(PPSSPPBlackberry add_executable(PPSSPPBlackberry native/base/BlackberryMain.cpp ${NativeAppSource})
native/base/BlackberryMain.cpp target_link_libraries(PPSSPPBlackberry ${LinkCommon} bps screen socket EGL GLESv2)
${NativeAppSource})
target_link_libraries(PPSSPPBlackberry ${LinkCommon}
bps screen socket EGL GLESv2)
elseif(ANDROID) elseif(ANDROID)
# no target # no target
else() else()
set(SDL_Main native/base/PCMain.cpp)
if(APPLE) if(APPLE)
set(SDL_Main set(SDL_Main ${SDL_Main}
SDL/SDLMain.h SDL/SDLMain.h
SDL/SDLMain.mm SDL/SDLMain.mm)
native/base/PCMain.cpp) find_library(COCOA_LIBRARY Cocoa)
else() set(LinkCommon ${LinkCommon} ${COCOA_LIBRARY})
set(SDL_Main
native/base/PCMain.cpp)
endif() endif()
add_executable(PPSSPPSDL ${SDL_Main} ${NativeAppSource}) add_executable(PPSSPPSDL ${SDL_Main} ${NativeAppSource})
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(PPSSPPSDL ${COCOA_LIBRARY} ${LinkCommon})
else()
target_link_libraries(PPSSPPSDL ${LinkCommon}) target_link_libraries(PPSSPPSDL ${LinkCommon})
endif() endif()
endif()
file(INSTALL ${AndroidAssets} DESTINATION assets) file(INSTALL ${AndroidAssets} DESTINATION assets)
endif() endif()