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
|
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} DOLPHIN) # defines DOLPHIN_WC_REVISION
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: Make this optional or even implement our own package detection
|
|
||||||
include(FindPkgConfig REQUIRED)
|
|
||||||
|
|
||||||
# Various compile flags
|
# Various compile flags
|
||||||
add_definitions(-msse2 -Wall)
|
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.
|
# be needed by users is optional defaulting to ON, other stuff (like e.g.
|
||||||
# sound backends) is completely optional.
|
# sound backends) is completely optional.
|
||||||
|
|
||||||
|
include(CheckLib)
|
||||||
|
|
||||||
include(FindOpenGL REQUIRED)
|
include(FindOpenGL REQUIRED)
|
||||||
include_directories(${OPENGL_INCLUDE_DIR})
|
include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
@ -108,7 +107,7 @@ else()
|
||||||
message("ALSA NOT found, disabling ALSA sound backend")
|
message("ALSA NOT found, disabling ALSA sound backend")
|
||||||
endif(ALSA_FOUND)
|
endif(ALSA_FOUND)
|
||||||
|
|
||||||
pkg_search_module(AO ao)
|
check_lib(AO ao QUIET)
|
||||||
if(AO_FOUND)
|
if(AO_FOUND)
|
||||||
add_definitions(-DHAVE_AO=1)
|
add_definitions(-DHAVE_AO=1)
|
||||||
include_directories(${AO_INCLUDE_DIRS})
|
include_directories(${AO_INCLUDE_DIRS})
|
||||||
|
@ -118,7 +117,7 @@ else()
|
||||||
message("ao NOT found, disabling ao sound backend")
|
message("ao NOT found, disabling ao sound backend")
|
||||||
endif(AO_FOUND)
|
endif(AO_FOUND)
|
||||||
|
|
||||||
pkg_search_module(BLUEZ bluez)
|
check_lib(BLUEZ bluez QUIET)
|
||||||
if(BLUEZ_FOUND)
|
if(BLUEZ_FOUND)
|
||||||
add_definitions(-DHAVE_BLUEZ=1)
|
add_definitions(-DHAVE_BLUEZ=1)
|
||||||
include_directories(${BLUEZ_INCLUDE_DIRS})
|
include_directories(${BLUEZ_INCLUDE_DIRS})
|
||||||
|
@ -128,7 +127,7 @@ else()
|
||||||
message("bluez NOT found, disabling bluetooth support")
|
message("bluez NOT found, disabling bluetooth support")
|
||||||
endif(BLUEZ_FOUND)
|
endif(BLUEZ_FOUND)
|
||||||
|
|
||||||
pkg_search_module(PULSEAUDIO libpulse)
|
check_lib(PULSEAUDIO libpulse QUIET)
|
||||||
if(PULSEAUDIO_FOUND)
|
if(PULSEAUDIO_FOUND)
|
||||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||||
include_directories(${PULSEAUDIO_INCLUDE_DIR})
|
include_directories(${PULSEAUDIO_INCLUDE_DIR})
|
||||||
|
@ -162,28 +161,16 @@ else()
|
||||||
add_definitions(-DHAVE_X11=0)
|
add_definitions(-DHAVE_X11=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
pkg_search_module(XRANDR xrandr)
|
check_lib(XRANDR Xrandr)
|
||||||
if(XRANDR_FOUND)
|
if(XRANDR_FOUND)
|
||||||
add_definitions(-DHAVE_XRANDR=1)
|
add_definitions(-DHAVE_XRANDR=1)
|
||||||
message("Xrandr found")
|
|
||||||
else()
|
else()
|
||||||
add_definitions(-DHAVE_XRANDR=0)
|
add_definitions(-DHAVE_XRANDR=0)
|
||||||
message("Xrandr NOT found")
|
|
||||||
endif(XRANDR_FOUND)
|
endif(XRANDR_FOUND)
|
||||||
|
|
||||||
option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
|
option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
|
||||||
if(ENCODE_FRAMEDUMPS)
|
if(ENCODE_FRAMEDUMPS)
|
||||||
pkg_search_module(AVCODEC libavcodec>=52.72.2)
|
check_libav()
|
||||||
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()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_program(XDG_SCREENSAVER xdg-screensaver)
|
find_program(XDG_SCREENSAVER xdg-screensaver)
|
||||||
|
@ -251,9 +238,7 @@ include_directories(Externals/Bochs_disasm)
|
||||||
add_subdirectory(Externals/Lua)
|
add_subdirectory(Externals/Lua)
|
||||||
include_directories(Externals/Lua)
|
include_directories(Externals/Lua)
|
||||||
|
|
||||||
include(CheckLib)
|
check_lib(LZO lzo2 lzo/lzo1x.h QUIET)
|
||||||
|
|
||||||
check_lib_and_header(LZO lzo2 lzo/lzo1x.h OPTIONAL)
|
|
||||||
if(LZO_FOUND)
|
if(LZO_FOUND)
|
||||||
message("Using shared lzo")
|
message("Using shared lzo")
|
||||||
include_directories(${LZO_INCLUDE})
|
include_directories(${LZO_INCLUDE})
|
||||||
|
@ -274,7 +259,7 @@ else(SDL_FOUND)
|
||||||
add_subdirectory(Externals/SDL)
|
add_subdirectory(Externals/SDL)
|
||||||
endif(SDL_FOUND)
|
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)
|
if(SFML_FOUND)
|
||||||
message("Using shared sfml-network")
|
message("Using shared sfml-network")
|
||||||
include_directories(${SFML_INCLUDE})
|
include_directories(${SFML_INCLUDE})
|
||||||
|
@ -284,7 +269,7 @@ else()
|
||||||
include_directories(Externals/SFML/include)
|
include_directories(Externals/SFML/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_lib_and_header(SOIL SOIL SOIL/SOIL.h OPTIONAL)
|
check_lib(SOIL SOIL SOIL/SOIL.h QUIET)
|
||||||
if(SOIL_FOUND)
|
if(SOIL_FOUND)
|
||||||
message("Using shared SOIL")
|
message("Using shared SOIL")
|
||||||
include_directories(${SOIL_INCLUDE})
|
include_directories(${SOIL_INCLUDE})
|
||||||
|
@ -294,8 +279,13 @@ else()
|
||||||
include_directories(Externals/SOIL)
|
include_directories(Externals/SOIL)
|
||||||
endif()
|
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)
|
if(ZLIB_FOUND)
|
||||||
|
set(ZLIB_FOUND 1 CACHE INTERNAL "")
|
||||||
message("Using shared zlib")
|
message("Using shared zlib")
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||||
else(ZLIB_FOUND)
|
else(ZLIB_FOUND)
|
||||||
|
@ -308,17 +298,18 @@ if(WIN32)
|
||||||
find_library(GLEW glew32s PATHS Externals/GLew)
|
find_library(GLEW glew32s PATHS Externals/GLew)
|
||||||
include_directories(Externals/GLew/include)
|
include_directories(Externals/GLew/include)
|
||||||
else()
|
else()
|
||||||
check_lib(GLU glu REQUIRED)
|
check_lib(GLU GLU GL/glu.h 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()
|
|
||||||
|
|
||||||
if(NOT GLEW_FOUND)
|
check_lib(GLEW GLEW GL/glew.h)
|
||||||
message("Shared GLEW not found, falling back to the static library")
|
if(NOT GLEW_FOUND)
|
||||||
add_subdirectory(Externals/GLew)
|
message("Shared GLEW not found, falling back to the static library")
|
||||||
include_directories(Externals/GLew/include)
|
add_subdirectory(Externals/GLew)
|
||||||
endif(NOT GLEW_FOUND)
|
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"))
|
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
|
||||||
include_directories(Externals/CLRun/include)
|
include_directories(Externals/CLRun/include)
|
||||||
|
@ -328,6 +319,7 @@ endif()
|
||||||
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
|
option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF)
|
||||||
if(NOT DISABLE_WX)
|
if(NOT DISABLE_WX)
|
||||||
include(FindwxWidgets OPTIONAL)
|
include(FindwxWidgets OPTIONAL)
|
||||||
|
FIND_PACKAGE(wxWidgets COMPONENTS aui)
|
||||||
|
|
||||||
if(wxWidgets_FOUND)
|
if(wxWidgets_FOUND)
|
||||||
include(${wxWidgets_USE_FILE})
|
include(${wxWidgets_USE_FILE})
|
||||||
|
|
|
@ -1,34 +1,64 @@
|
||||||
macro(check_lib var lib required)
|
include(FindPkgConfig OPTIONAL)
|
||||||
pkg_search_module(${var} ${lib})
|
|
||||||
|
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)
|
if(${var}_FOUND)
|
||||||
message("${lib} found")
|
_internal_message("${lib} found" _is_quiet)
|
||||||
else()
|
else()
|
||||||
find_library(${var} ${lib})
|
find_library(${var} ${lib})
|
||||||
if(${var})
|
foreach(_file ${ARGN})
|
||||||
message("${lib} found")
|
find_path(${var}_INCLUDE ${_file})
|
||||||
|
endforeach()
|
||||||
|
if(${var} AND ${var}_INCLUDE)
|
||||||
|
_internal_message("${lib} found" _is_quiet)
|
||||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
set(${var}_FOUND 1 CACHE INTERNAL "")
|
||||||
else()
|
else()
|
||||||
if(${required} STREQUAL "REQUIRED")
|
if(_is_required)
|
||||||
message(FATAL_ERROR "${lib} is required but not found")
|
message(FATAL_ERROR "${lib} is required but not found")
|
||||||
else()
|
else()
|
||||||
message("${lib} not found")
|
_internal_message("${lib} not found" _is_quiet)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(check_lib_and_header var lib header required)
|
macro(check_libav)
|
||||||
find_library(${var} ${lib})
|
if(PKG_CONFIG_FOUND)
|
||||||
find_path(${var}_INCLUDE ${header})
|
pkg_check_modules(LIBAV libavcodec>=52.72.2 libavformat>=52.64.2
|
||||||
if(${var} AND ${var}_INCLUDE)
|
libswscale>=0.11.0 libavutil>=50.15.1)
|
||||||
message("${lib} found")
|
|
||||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
|
||||||
else()
|
else()
|
||||||
if(${required} STREQUAL "REQUIRED")
|
message("pkg-config is required to check for libav")
|
||||||
message(FATAL_ERROR "${lib} is required but not found")
|
endif()
|
||||||
else()
|
if(LIBAV_FOUND)
|
||||||
message("${lib} not found")
|
message("libav found, enabling AVI frame dumps")
|
||||||
endif()
|
add_definitions(-DHAVE_LIBAV)
|
||||||
|
else()
|
||||||
|
message("libav not found, disabling AVI frame dumps")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,14 @@ set(SRCS Src/BPMemory.cpp
|
||||||
Src/XFStructs.cpp
|
Src/XFStructs.cpp
|
||||||
Src/OpenCL/OCLTextureDecoder.cpp)
|
Src/OpenCL/OCLTextureDecoder.cpp)
|
||||||
|
|
||||||
if(ENCODE_FRAMEDUMPS OR WIN32)
|
if(LIBAV_FOUND OR WIN32)
|
||||||
set(SRCS ${SRCS} Src/AVIDump.cpp)
|
set(SRCS ${SRCS} Src/AVIDump.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(videocommon STATIC ${SRCS})
|
add_library(videocommon STATIC ${SRCS})
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
if(ENCODE_FRAMEDUMPS)
|
if(LIBAV_FOUND)
|
||||||
target_link_libraries(videocommon avcodec avformat swscale avutil)
|
target_link_libraries(videocommon ${LIBAV_LIBRARIES})
|
||||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||||
endif()
|
endif()
|
||||||
add_definitions(-fPIC)
|
add_definitions(-fPIC)
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "OS/Win32.h"
|
#include "OS/Win32.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
#if defined _WIN32 || defined HAVE_LIBAV
|
||||||
#include "AVIDump.h"
|
#include "AVIDump.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ CGprofile g_cgfProf;
|
||||||
|
|
||||||
RasterFont* s_pfont = NULL;
|
RasterFont* s_pfont = NULL;
|
||||||
|
|
||||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
#if defined _WIN32 || defined HAVE_LIBAV
|
||||||
static bool s_bAVIDumping = false;
|
static bool s_bAVIDumping = false;
|
||||||
#else
|
#else
|
||||||
static FILE* f_pFrameDump;
|
static FILE* f_pFrameDump;
|
||||||
|
@ -492,7 +492,7 @@ Renderer::~Renderer()
|
||||||
|
|
||||||
delete g_framebuffer_manager;
|
delete g_framebuffer_manager;
|
||||||
|
|
||||||
#if defined _WIN32 || defined HAVE_AVCODEC
|
#if defined _WIN32 || defined HAVE_LIBAV
|
||||||
if(s_bAVIDumping)
|
if(s_bAVIDumping)
|
||||||
AVIDump::Stop();
|
AVIDump::Stop();
|
||||||
#else
|
#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
|
// 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)
|
if (g_ActiveConfig.bDumpFrames)
|
||||||
{
|
{
|
||||||
s_criticalScreenshot.Enter();
|
s_criticalScreenshot.Enter();
|
||||||
|
|
Loading…
Reference in New Issue