Make the cmake check_lib macro more versatile. It first tries pkg-config, and if that fails it then check for libraries and required headers. Also cleaned up the output a little bit.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6544 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
c718d2e630
commit
06013d5eec
|
@ -29,9 +29,6 @@ if(Subversion_FOUND AND NOT DOLPHIN_WC_REVISION)
|
|||
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} DOLPHIN) # defines DOLPHIN_WC_REVISION
|
||||
endif()
|
||||
|
||||
# TODO: Make this optional or even implement our own package detection
|
||||
include(FindPkgConfig REQUIRED)
|
||||
|
||||
# Various compile flags
|
||||
add_definitions(-msse2 -Wall)
|
||||
|
||||
|
@ -96,6 +93,8 @@ endif(CMAKE_BUILD_TYPE STREQUAL Release)
|
|||
# be needed by users is optional defaulting to ON, other stuff (like e.g.
|
||||
# sound backends) is completely optional.
|
||||
|
||||
include(CheckLib)
|
||||
|
||||
include(FindOpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
||||
|
@ -108,7 +107,7 @@ else()
|
|||
message("ALSA NOT found, disabling ALSA sound backend")
|
||||
endif(ALSA_FOUND)
|
||||
|
||||
pkg_search_module(AO ao)
|
||||
check_lib(AO ao QUIET)
|
||||
if(AO_FOUND)
|
||||
add_definitions(-DHAVE_AO=1)
|
||||
include_directories(${AO_INCLUDE_DIRS})
|
||||
|
@ -118,7 +117,7 @@ else()
|
|||
message("ao NOT found, disabling ao sound backend")
|
||||
endif(AO_FOUND)
|
||||
|
||||
pkg_search_module(BLUEZ bluez)
|
||||
check_lib(BLUEZ bluez QUIET)
|
||||
if(BLUEZ_FOUND)
|
||||
add_definitions(-DHAVE_BLUEZ=1)
|
||||
include_directories(${BLUEZ_INCLUDE_DIRS})
|
||||
|
@ -128,7 +127,7 @@ else()
|
|||
message("bluez NOT found, disabling bluetooth support")
|
||||
endif(BLUEZ_FOUND)
|
||||
|
||||
pkg_search_module(PULSEAUDIO libpulse)
|
||||
check_lib(PULSEAUDIO libpulse QUIET)
|
||||
if(PULSEAUDIO_FOUND)
|
||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||
include_directories(${PULSEAUDIO_INCLUDE_DIR})
|
||||
|
@ -162,28 +161,16 @@ else()
|
|||
add_definitions(-DHAVE_X11=0)
|
||||
endif()
|
||||
|
||||
pkg_search_module(XRANDR xrandr)
|
||||
check_lib(XRANDR Xrandr)
|
||||
if(XRANDR_FOUND)
|
||||
add_definitions(-DHAVE_XRANDR=1)
|
||||
message("Xrandr found")
|
||||
else()
|
||||
add_definitions(-DHAVE_XRANDR=0)
|
||||
message("Xrandr NOT found")
|
||||
endif(XRANDR_FOUND)
|
||||
|
||||
option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
|
||||
if(ENCODE_FRAMEDUMPS)
|
||||
pkg_search_module(AVCODEC libavcodec>=52.72.2)
|
||||
pkg_search_module(AVFORMAT libavformat>=52.64.2)
|
||||
pkg_search_module(SWSCALE libswscale>=0.11.0)
|
||||
if(AVCODEC_FOUND AND AVFORMAT_FOUND AND SWSCALE_FOUND)
|
||||
message("libav found, enabling AVI frame dumps")
|
||||
set(ENCODE_FRAMEDUMPS ON)
|
||||
add_definitions(-DHAVE_AVCODEC)
|
||||
else()
|
||||
set(ENCODE_FRAMEDUMPS OFF)
|
||||
message("libav not found, disabling AVI frame dumps")
|
||||
endif()
|
||||
check_libav()
|
||||
endif()
|
||||
|
||||
find_program(XDG_SCREENSAVER xdg-screensaver)
|
||||
|
@ -251,9 +238,7 @@ include_directories(Externals/Bochs_disasm)
|
|||
add_subdirectory(Externals/Lua)
|
||||
include_directories(Externals/Lua)
|
||||
|
||||
include(CheckLib)
|
||||
|
||||
check_lib_and_header(LZO lzo2 lzo/lzo1x.h OPTIONAL)
|
||||
check_lib(LZO lzo2 lzo/lzo1x.h QUIET)
|
||||
if(LZO_FOUND)
|
||||
message("Using shared lzo")
|
||||
include_directories(${LZO_INCLUDE})
|
||||
|
@ -274,7 +259,7 @@ else(SDL_FOUND)
|
|||
add_subdirectory(Externals/SDL)
|
||||
endif(SDL_FOUND)
|
||||
|
||||
check_lib_and_header(SFML sfml-network SFML/Network/Ftp.hpp OPTIONAL)
|
||||
check_lib(SFML sfml-network SFML/Network/Ftp.hpp QUIET)
|
||||
if(SFML_FOUND)
|
||||
message("Using shared sfml-network")
|
||||
include_directories(${SFML_INCLUDE})
|
||||
|
@ -284,7 +269,7 @@ else()
|
|||
include_directories(Externals/SFML/include)
|
||||
endif()
|
||||
|
||||
check_lib_and_header(SOIL SOIL SOIL/SOIL.h OPTIONAL)
|
||||
check_lib(SOIL SOIL SOIL/SOIL.h QUIET)
|
||||
if(SOIL_FOUND)
|
||||
message("Using shared SOIL")
|
||||
include_directories(${SOIL_INCLUDE})
|
||||
|
@ -294,8 +279,13 @@ else()
|
|||
include_directories(Externals/SOIL)
|
||||
endif()
|
||||
|
||||
include(FindZLIB OPTIONAL)
|
||||
# If zlib has already been found on a previous run of cmake don't check again
|
||||
# as the check seems to take a long time.
|
||||
if(NOT ZLIB_FOUND)
|
||||
include(FindZLIB OPTIONAL)
|
||||
endif()
|
||||
if(ZLIB_FOUND)
|
||||
set(ZLIB_FOUND 1 CACHE INTERNAL "")
|
||||
message("Using shared zlib")
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
else(ZLIB_FOUND)
|
||||
|
@ -308,17 +298,18 @@ if(WIN32)
|
|||
find_library(GLEW glew32s PATHS Externals/GLew)
|
||||
include_directories(Externals/GLew/include)
|
||||
else()
|
||||
check_lib(GLU glu REQUIRED)
|
||||
check_lib_and_header(GLEW GLEW GL/glew.h OPTIONAL)
|
||||
check_lib_and_header(CG Cg Cg/cg.h OPTIONAL)
|
||||
check_lib_and_header(CGGL CgGL Cg/cgGL.h OPTIONAL)
|
||||
endif()
|
||||
check_lib(GLU GLU GL/glu.h REQUIRED)
|
||||
|
||||
if(NOT GLEW_FOUND)
|
||||
message("Shared GLEW not found, falling back to the static library")
|
||||
add_subdirectory(Externals/GLew)
|
||||
include_directories(Externals/GLew/include)
|
||||
endif(NOT GLEW_FOUND)
|
||||
check_lib(GLEW GLEW GL/glew.h)
|
||||
if(NOT GLEW_FOUND)
|
||||
message("Shared GLEW not found, falling back to the static library")
|
||||
add_subdirectory(Externals/GLew)
|
||||
include_directories(Externals/GLew/include)
|
||||
endif(NOT GLEW_FOUND)
|
||||
|
||||
check_lib(CG Cg Cg/cg.h)
|
||||
check_lib(CGGL CgGL Cg/cgGL.h)
|
||||
endif()
|
||||
|
||||
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
|
||||
include_directories(Externals/CLRun/include)
|
||||
|
@ -328,6 +319,7 @@ endif()
|
|||
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
|
||||
if(NOT DISABLE_WX)
|
||||
include(FindwxWidgets OPTIONAL)
|
||||
FIND_PACKAGE(wxWidgets COMPONENTS aui)
|
||||
|
||||
if(wxWidgets_FOUND)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
|
|
|
@ -1,34 +1,64 @@
|
|||
macro(check_lib var lib required)
|
||||
pkg_search_module(${var} ${lib})
|
||||
include(FindPkgConfig OPTIONAL)
|
||||
|
||||
macro(_internal_message msg _quiet)
|
||||
if(NOT _quiet)
|
||||
message("${msg}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_lib var lib)
|
||||
set(_is_required 0)
|
||||
set(_is_quiet 0)
|
||||
foreach(_arg ${ARGN})
|
||||
if(_arg STREQUAL "REQUIRED")
|
||||
set(_is_required 1)
|
||||
endif()
|
||||
if(_arg STREQUAL "QUIET")
|
||||
set(_is_quiet 1)
|
||||
endif()
|
||||
endforeach()
|
||||
if(ARGN)
|
||||
list(REMOVE_ITEM ${ARGN} "REQUIRED")
|
||||
list(REMOVE_ITEM ${ARGN} "QUIET")
|
||||
endif()
|
||||
|
||||
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND)
|
||||
string(TOLOWER ${lib} lower_lib)
|
||||
pkg_search_module(${var} QUIET ${lower_lib})
|
||||
endif()
|
||||
|
||||
if(${var}_FOUND)
|
||||
message("${lib} found")
|
||||
_internal_message("${lib} found" _is_quiet)
|
||||
else()
|
||||
find_library(${var} ${lib})
|
||||
if(${var})
|
||||
message("${lib} found")
|
||||
foreach(_file ${ARGN})
|
||||
find_path(${var}_INCLUDE ${_file})
|
||||
endforeach()
|
||||
if(${var} AND ${var}_INCLUDE)
|
||||
_internal_message("${lib} found" _is_quiet)
|
||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
||||
else()
|
||||
if(${required} STREQUAL "REQUIRED")
|
||||
if(_is_required)
|
||||
message(FATAL_ERROR "${lib} is required but not found")
|
||||
else()
|
||||
message("${lib} not found")
|
||||
_internal_message("${lib} not found" _is_quiet)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_lib_and_header var lib header required)
|
||||
find_library(${var} ${lib})
|
||||
find_path(${var}_INCLUDE ${header})
|
||||
if(${var} AND ${var}_INCLUDE)
|
||||
message("${lib} found")
|
||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
||||
macro(check_libav)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBAV libavcodec>=52.72.2 libavformat>=52.64.2
|
||||
libswscale>=0.11.0 libavutil>=50.15.1)
|
||||
else()
|
||||
if(${required} STREQUAL "REQUIRED")
|
||||
message(FATAL_ERROR "${lib} is required but not found")
|
||||
else()
|
||||
message("${lib} not found")
|
||||
endif()
|
||||
message("pkg-config is required to check for libav")
|
||||
endif()
|
||||
if(LIBAV_FOUND)
|
||||
message("libav found, enabling AVI frame dumps")
|
||||
add_definitions(-DHAVE_LIBAV)
|
||||
else()
|
||||
message("libav not found, disabling AVI frame dumps")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ set(SRCS Src/BPMemory.cpp
|
|||
Src/XFStructs.cpp
|
||||
Src/OpenCL/OCLTextureDecoder.cpp)
|
||||
|
||||
if(ENCODE_FRAMEDUMPS OR WIN32)
|
||||
if(LIBAV_FOUND OR WIN32)
|
||||
set(SRCS ${SRCS} Src/AVIDump.cpp)
|
||||
endif()
|
||||
|
||||
add_library(videocommon STATIC ${SRCS})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if(ENCODE_FRAMEDUMPS)
|
||||
target_link_libraries(videocommon avcodec avformat swscale avutil)
|
||||
if(LIBAV_FOUND)
|
||||
target_link_libraries(videocommon ${LIBAV_LIBRARIES})
|
||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||
endif()
|
||||
add_definitions(-fPIC)
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#ifdef _WIN32
|
||||
#include "OS/Win32.h"
|
||||
#endif
|
||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
||||
#if defined _WIN32 || defined HAVE_LIBAV
|
||||
#include "AVIDump.h"
|
||||
#endif
|
||||
|
||||
|
@ -83,7 +83,7 @@ CGprofile g_cgfProf;
|
|||
|
||||
RasterFont* s_pfont = NULL;
|
||||
|
||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
||||
#if defined _WIN32 || defined HAVE_LIBAV
|
||||
static bool s_bAVIDumping = false;
|
||||
#else
|
||||
static FILE* f_pFrameDump;
|
||||
|
@ -492,7 +492,7 @@ Renderer::~Renderer()
|
|||
|
||||
delete g_framebuffer_manager;
|
||||
|
||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
||||
#if defined _WIN32 || defined HAVE_LIBAV
|
||||
if(s_bAVIDumping)
|
||||
AVIDump::Stop();
|
||||
#else
|
||||
|
@ -1102,7 +1102,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
}
|
||||
|
||||
// Frame dumps are handled a little differently in Windows
|
||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
||||
#if defined _WIN32 || defined HAVE_LIBAV
|
||||
if (g_ActiveConfig.bDumpFrames)
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
|
|
Loading…
Reference in New Issue