mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-08 15:20:45 +01:00
CMakeLists cleanup and enable Android headless building.
This commit is contained in:
parent
6305f09467
commit
2f7e3ae58e
304
CMakeLists.txt
304
CMakeLists.txt
@ -375,10 +375,24 @@ endif(VTUNE)
|
||||
|
||||
if(ANDROID)
|
||||
message("Building for Android")
|
||||
add_definitions(-DANDROID)
|
||||
if(NOT ENABLE_HEADLESS)
|
||||
add_definitions(-DANDROID)
|
||||
else()
|
||||
# Lie to cmake a bit. We are cross compiling to Android
|
||||
# but not as a shared library. We want an executable.
|
||||
set(ANDROID 0)
|
||||
endif()
|
||||
set(USE_X11 0)
|
||||
set(USE_UPNP 0)
|
||||
set(USE_EGL 1)
|
||||
set(DISABLE_WX 1)
|
||||
set(ENABLE_QT2 0)
|
||||
|
||||
# We are cross compiling, search only the toolchain for libraries and includes
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
elseif(NOT APPLE)
|
||||
list(APPEND LIBS rt)
|
||||
endif()
|
||||
|
||||
if(ENABLE_HEADLESS)
|
||||
@ -390,8 +404,6 @@ if(ENABLE_HEADLESS)
|
||||
add_definitions(-DUSE_HEADLESS)
|
||||
endif()
|
||||
|
||||
include_directories(Externals/GL)
|
||||
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
|
||||
|
||||
########################################
|
||||
@ -403,140 +415,139 @@ add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
|
||||
include(CheckLib)
|
||||
include(CheckCXXSourceRuns)
|
||||
|
||||
if(NOT ANDROID)
|
||||
|
||||
include(FindOpenGL)
|
||||
include(FindOpenGL)
|
||||
if (OPENGL_GL)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
include(FindALSA OPTIONAL)
|
||||
if(ALSA_FOUND)
|
||||
add_definitions(-DHAVE_ALSA=1)
|
||||
message("ALSA found, enabling ALSA sound backend")
|
||||
include(FindALSA OPTIONAL)
|
||||
if(ALSA_FOUND)
|
||||
add_definitions(-DHAVE_ALSA=1)
|
||||
message("ALSA found, enabling ALSA sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_ALSA=0)
|
||||
message("ALSA NOT found, disabling ALSA sound backend")
|
||||
endif(ALSA_FOUND)
|
||||
|
||||
check_lib(AO ao ao QUIET)
|
||||
if(AO_FOUND)
|
||||
add_definitions(-DHAVE_AO=1)
|
||||
message("ao found, enabling ao sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_AO=0)
|
||||
message("ao NOT found, disabling ao sound backend")
|
||||
endif(AO_FOUND)
|
||||
|
||||
check_lib(BLUEZ bluez bluez QUIET)
|
||||
if(BLUEZ_FOUND)
|
||||
add_definitions(-DHAVE_BLUEZ=1)
|
||||
message("bluez found, enabling bluetooth support")
|
||||
else()
|
||||
add_definitions(-DHAVE_BLUEZ=0)
|
||||
message("bluez NOT found, disabling bluetooth support")
|
||||
endif(BLUEZ_FOUND)
|
||||
|
||||
check_lib(PULSEAUDIO libpulse pulse QUIET)
|
||||
if(PULSEAUDIO_FOUND)
|
||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||
message("PulseAudio found, enabling PulseAudio sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_PULSEAUDIO=0)
|
||||
message("PulseAudio NOT found, disabling PulseAudio sound backend")
|
||||
endif(PULSEAUDIO_FOUND)
|
||||
|
||||
include(FindOpenAL OPTIONAL)
|
||||
if(OPENAL_FOUND)
|
||||
add_definitions(-DHAVE_OPENAL=1)
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
message("OpenAL found, enabling OpenAL sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_OPENAL=0)
|
||||
message("OpenAL NOT found, disabling OpenAL sound backend")
|
||||
endif(OPENAL_FOUND)
|
||||
|
||||
include(FindLLVM OPTIONAL)
|
||||
if (LLVM_FOUND)
|
||||
add_definitions(-DHAS_LLVM=1)
|
||||
set(HAS_LLVM 1)
|
||||
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
list(APPEND LIBS ${LLVM_LIBRARIES})
|
||||
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
endif()
|
||||
|
||||
set(USE_X11 0)
|
||||
|
||||
if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS)
|
||||
include(FindX11)
|
||||
if(TRY_X11 AND X11_FOUND)
|
||||
set(USE_X11 1)
|
||||
add_definitions(-DHAVE_X11=1)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
message("X11 support enabled")
|
||||
else()
|
||||
add_definitions(-DHAVE_ALSA=0)
|
||||
message("ALSA NOT found, disabling ALSA sound backend")
|
||||
endif(ALSA_FOUND)
|
||||
set(USE_X11 0)
|
||||
SET(X11_FOUND "")
|
||||
message("X11 support disabled")
|
||||
add_definitions(-DHAVE_X11=0)
|
||||
endif(TRY_X11 AND X11_FOUND)
|
||||
|
||||
check_lib(AO ao ao QUIET)
|
||||
if(AO_FOUND)
|
||||
add_definitions(-DHAVE_AO=1)
|
||||
message("ao found, enabling ao sound backend")
|
||||
if (NOT USE_X11)
|
||||
message(FATAL_ERROR "\n"
|
||||
"No suitable display platform found\n"
|
||||
"Requires x11 to run")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_X11)
|
||||
check_lib(XRANDR xrandr Xrandr)
|
||||
if(XRANDR_FOUND)
|
||||
add_definitions(-DHAVE_XRANDR=1)
|
||||
else()
|
||||
add_definitions(-DHAVE_AO=0)
|
||||
message("ao NOT found, disabling ao sound backend")
|
||||
endif(AO_FOUND)
|
||||
add_definitions(-DHAVE_XRANDR=0)
|
||||
endif(XRANDR_FOUND)
|
||||
|
||||
check_lib(BLUEZ bluez bluez QUIET)
|
||||
if(BLUEZ_FOUND)
|
||||
add_definitions(-DHAVE_BLUEZ=1)
|
||||
message("bluez found, enabling bluetooth support")
|
||||
pkg_check_modules(XINPUT2 xi>=1.5.0)
|
||||
if(XINPUT2_FOUND)
|
||||
add_definitions(-DHAVE_X11_XINPUT2=1)
|
||||
else()
|
||||
add_definitions(-DHAVE_BLUEZ=0)
|
||||
message("bluez NOT found, disabling bluetooth support")
|
||||
endif(BLUEZ_FOUND)
|
||||
|
||||
check_lib(PULSEAUDIO libpulse pulse QUIET)
|
||||
if(PULSEAUDIO_FOUND)
|
||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||
message("PulseAudio found, enabling PulseAudio sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_PULSEAUDIO=0)
|
||||
message("PulseAudio NOT found, disabling PulseAudio sound backend")
|
||||
endif(PULSEAUDIO_FOUND)
|
||||
|
||||
include(FindOpenAL OPTIONAL)
|
||||
if(OPENAL_FOUND)
|
||||
add_definitions(-DHAVE_OPENAL=1)
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
message("OpenAL found, enabling OpenAL sound backend")
|
||||
else()
|
||||
add_definitions(-DHAVE_OPENAL=0)
|
||||
message("OpenAL NOT found, disabling OpenAL sound backend")
|
||||
endif(OPENAL_FOUND)
|
||||
|
||||
include(FindLLVM OPTIONAL)
|
||||
if (LLVM_FOUND)
|
||||
add_definitions(-DHAS_LLVM=1)
|
||||
set(HAS_LLVM 1)
|
||||
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
list(APPEND LIBS ${LLVM_LIBRARIES})
|
||||
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
add_definitions(-DHAVE_X11_XINPUT2=0)
|
||||
endif(XINPUT2_FOUND)
|
||||
endif()
|
||||
if(ENCODE_FRAMEDUMPS)
|
||||
check_libav()
|
||||
if(LIBAV_FOUND)
|
||||
LIST(APPEND LIBS ${LIBAV_LDFLAGS})
|
||||
endif()
|
||||
|
||||
set(USE_X11 0)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE AND NOT ENABLE_HEADLESS)
|
||||
include(FindX11)
|
||||
if(TRY_X11 AND X11_FOUND)
|
||||
set(USE_X11 1)
|
||||
add_definitions(-DHAVE_X11=1)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
message("X11 support enabled")
|
||||
else()
|
||||
set(USE_X11 0)
|
||||
SET(X11_FOUND "")
|
||||
message("X11 support disabled")
|
||||
add_definitions(-DHAVE_X11=0)
|
||||
endif(TRY_X11 AND X11_FOUND)
|
||||
set(CMAKE_REQUIRED_LIBRARIES portaudio)
|
||||
CHECK_CXX_SOURCE_RUNS(
|
||||
"#include <portaudio.h>
|
||||
int main(int argc, char **argv)
|
||||
{ if(Pa_GetVersion() >= 1890) return 0; else return 1; }"
|
||||
PORTAUDIO)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
if(PORTAUDIO)
|
||||
message("PortAudio found, enabling mic support")
|
||||
add_definitions(-DHAVE_PORTAUDIO=1)
|
||||
set(PORTAUDIO_FOUND TRUE)
|
||||
else()
|
||||
message("PortAudio not found, disabling mic support")
|
||||
add_definitions(-DHAVE_PORTAUDIO=0)
|
||||
set(PORTAUDIO_FOUND FALSE)
|
||||
endif(PORTAUDIO)
|
||||
|
||||
if (NOT USE_X11)
|
||||
message(FATAL_ERROR "\n"
|
||||
"No suitable display platform found\n"
|
||||
"Requires x11 to run")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_X11)
|
||||
check_lib(XRANDR xrandr Xrandr)
|
||||
if(XRANDR_FOUND)
|
||||
add_definitions(-DHAVE_XRANDR=1)
|
||||
else()
|
||||
add_definitions(-DHAVE_XRANDR=0)
|
||||
endif(XRANDR_FOUND)
|
||||
|
||||
pkg_check_modules(XINPUT2 xi>=1.5.0)
|
||||
if(XINPUT2_FOUND)
|
||||
add_definitions(-DHAVE_X11_XINPUT2=1)
|
||||
else()
|
||||
add_definitions(-DHAVE_X11_XINPUT2=0)
|
||||
endif(XINPUT2_FOUND)
|
||||
endif()
|
||||
if(ENCODE_FRAMEDUMPS)
|
||||
check_libav()
|
||||
if(LIBAV_FOUND)
|
||||
LIST(APPEND LIBS ${LIBAV_LDFLAGS})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES portaudio)
|
||||
CHECK_CXX_SOURCE_RUNS(
|
||||
"#include <portaudio.h>
|
||||
int main(int argc, char **argv)
|
||||
{ if(Pa_GetVersion() >= 1890) return 0; else return 1; }"
|
||||
PORTAUDIO)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
if(PORTAUDIO)
|
||||
message("PortAudio found, enabling mic support")
|
||||
add_definitions(-DHAVE_PORTAUDIO=1)
|
||||
set(PORTAUDIO_FOUND TRUE)
|
||||
if(OPROFILING)
|
||||
include(FindOProfile)
|
||||
if(OPROFILE_FOUND)
|
||||
message("OProfile found, enabling profiling support")
|
||||
add_definitions(-DUSE_OPROFILE=1)
|
||||
include_directories(${OPROFILE_INCLUDE_DIRS})
|
||||
else()
|
||||
message("PortAudio not found, disabling mic support")
|
||||
add_definitions(-DHAVE_PORTAUDIO=0)
|
||||
set(PORTAUDIO_FOUND FALSE)
|
||||
endif(PORTAUDIO)
|
||||
|
||||
if(OPROFILING)
|
||||
include(FindOProfile)
|
||||
if(OPROFILE_FOUND)
|
||||
message("OProfile found, enabling profiling support")
|
||||
add_definitions(-DUSE_OPROFILE=1)
|
||||
include_directories(${OPROFILE_INCLUDE_DIRS})
|
||||
else()
|
||||
message(FATAL_ERROR "OProfile not found. Can't build profiling support.")
|
||||
endif()
|
||||
message(FATAL_ERROR "OProfile not found. Can't build profiling support.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -586,7 +597,7 @@ endif()
|
||||
add_subdirectory(Externals/Bochs_disasm)
|
||||
include_directories(Externals/Bochs_disasm)
|
||||
|
||||
if(NOT ANDROID AND USE_SHARED_ENET)
|
||||
if(USE_SHARED_ENET)
|
||||
check_lib(ENET libenet enet enet/enet.h QUIET)
|
||||
include(CheckSymbolExists)
|
||||
if (ENET_FOUND)
|
||||
@ -636,7 +647,7 @@ else(ZLIB_FOUND)
|
||||
include_directories(Externals/zlib)
|
||||
endif(ZLIB_FOUND)
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
|
||||
endif()
|
||||
if(LZO_FOUND)
|
||||
@ -649,7 +660,7 @@ else()
|
||||
endif()
|
||||
list(APPEND LIBS ${LZO})
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
check_lib(PNG libpng png png.h QUIET)
|
||||
endif()
|
||||
if (PNG_FOUND)
|
||||
@ -701,7 +712,7 @@ if(LIBUSB_FOUND)
|
||||
endif(LIBUSB_FOUND)
|
||||
|
||||
set(SFML_REQD_VERSION 2.1)
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
|
||||
endif()
|
||||
if(SFML_FOUND)
|
||||
@ -714,7 +725,7 @@ else()
|
||||
endif()
|
||||
|
||||
if(USE_UPNP)
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
include(FindMiniupnpc)
|
||||
endif()
|
||||
if(MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8)
|
||||
@ -730,7 +741,7 @@ if(USE_UPNP)
|
||||
list(APPEND LIBS ${MINIUPNPC_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
include(FindMbedTLS)
|
||||
endif()
|
||||
if(MBEDTLS_FOUND)
|
||||
@ -743,7 +754,7 @@ else()
|
||||
include_directories(Externals/mbedtls/include)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
if(NOT APPLE)
|
||||
check_lib(SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET)
|
||||
endif()
|
||||
if(SOIL_FOUND)
|
||||
@ -754,16 +765,27 @@ else()
|
||||
include_directories(Externals/SOIL)
|
||||
endif()
|
||||
|
||||
if (ANDROID)
|
||||
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
|
||||
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
|
||||
|
||||
if (ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
|
||||
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
|
||||
else()
|
||||
message("Using static iconv from Externals")
|
||||
include_directories(Externals/libiconv-1.14/include)
|
||||
add_subdirectory(Externals/libiconv-1.14)
|
||||
list(APPEND LIBS iconv)
|
||||
else()
|
||||
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
|
||||
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
|
||||
list(APPEND LIBS ${ICONV_LIBRARIES})
|
||||
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
|
||||
set(ICONV_LIBRARIES iconv)
|
||||
endif()
|
||||
list(APPEND LIBS ${ICONV_LIBRARIES})
|
||||
|
||||
find_library(OPENSLES_LIBRARIES NAMES OpenSLES)
|
||||
find_path(OPENSLES_INCLUDE_DIR NAMES SLES/OpenSLES.h)
|
||||
|
||||
if (OPENSLES_LIBRARIES AND OPENSLES_INCLUDE_DIR)
|
||||
set(OPENSLES_FOUND 1)
|
||||
add_definitions(-DHAVE_OPENSLES=1)
|
||||
include_directories(${OPENSLES_INCLUDE_DIR})
|
||||
message("OpenSLES found, enabling OpenSLES sound backend")
|
||||
endif()
|
||||
|
||||
if(ENABLE_QT2)
|
||||
@ -771,7 +793,7 @@ if(ENABLE_QT2)
|
||||
message("Found Qt version ${Qt5Core_VERSION}, enabling the Qt backend")
|
||||
endif()
|
||||
|
||||
if(NOT DISABLE_WX AND NOT ANDROID)
|
||||
if(NOT DISABLE_WX)
|
||||
include(FindwxWidgets OPTIONAL)
|
||||
FIND_PACKAGE(wxWidgets COMPONENTS core aui adv)
|
||||
|
||||
@ -845,7 +867,7 @@ if(NOT DISABLE_WX AND NOT ANDROID)
|
||||
set(wxWidgets_LIBRARIES "wx")
|
||||
endif(wxWidgets_FOUND)
|
||||
add_definitions(-DHAVE_WX=1)
|
||||
endif(NOT DISABLE_WX AND NOT ANDROID)
|
||||
endif(NOT DISABLE_WX)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD")
|
||||
set(LIBS ${LIBS} usbhid)
|
||||
|
@ -6,10 +6,10 @@ set(SRCS AudioCommon.cpp
|
||||
|
||||
set(LIBS "")
|
||||
|
||||
if(ANDROID)
|
||||
if(OPENSLES_FOUND)
|
||||
set(SRCS ${SRCS} OpenSLESStream.cpp)
|
||||
set(LIBS ${LIBS} OpenSLES)
|
||||
endif(ANDROID)
|
||||
set(LIBS ${LIBS} ${OPENSLES_LIBRARIES})
|
||||
endif(OPENSLES_FOUND)
|
||||
|
||||
if(ALSA_FOUND)
|
||||
set(SRCS ${SRCS} AlsaSoundStream.cpp)
|
||||
|
@ -61,9 +61,6 @@ else()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBS "${CMAKE_THREAD_LIBS_INIT}" ${VTUNE_LIBRARIES})
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
list(APPEND LIBS rt)
|
||||
endif()
|
||||
|
||||
# OpenGL Interface
|
||||
set(SRCS ${SRCS}
|
||||
|
Loading…
Reference in New Issue
Block a user