* Select automatically module (include pcsx2, libutilities&libx86emitter) to build based on dependency available.
* rewrite SearchForStuff. More clean and it will better support mix between library and 3rdparty on linux. (see issue 736)


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3153 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2010-06-04 17:17:55 +00:00
parent 149d3290db
commit 03f96b29c5
3 changed files with 179 additions and 174 deletions

View File

@ -32,8 +32,7 @@ include(SearchForStuff)
include(SelectPcsx2Plugins) include(SelectPcsx2Plugins)
# add additional project-wide include directories # add additional project-wide include directories
include_directories(${PROJECT_SOURCE_DIR}/3rdparty include_directories(${PROJECT_SOURCE_DIR}/common/include
${PROJECT_SOURCE_DIR}/common/include
${PROJECT_SOURCE_DIR}/common/include/Utilities ${PROJECT_SOURCE_DIR}/common/include/Utilities
${PROJECT_SOURCE_DIR}/common/include/x86emitter) ${PROJECT_SOURCE_DIR}/common/include/x86emitter)
@ -41,13 +40,17 @@ include_directories(${PROJECT_SOURCE_DIR}/3rdparty
add_subdirectory(3rdparty) add_subdirectory(3rdparty)
# make common # make common
add_subdirectory(common) if(common_libs)
add_subdirectory(common)
endif(common_libs)
# make tools # make tools
add_subdirectory(tools) add_subdirectory(tools)
# make pcsx2 # make pcsx2
add_subdirectory(pcsx2) if(pcsx2_core)
add_subdirectory(pcsx2)
endif(pcsx2_core)
# make plugins # make plugins
add_subdirectory(plugins) add_subdirectory(plugins)

View File

@ -16,215 +16,176 @@ detectOperatingSystem()
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS " ") SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS " ")
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS " ") SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS " ")
#-------------------------------------------------------------------------------
# Search all libraries on the system
#-------------------------------------------------------------------------------
# Do not search Lib in /usr/lib64. Hope it is not overwritten in find_package or others macro # Do not search Lib in /usr/lib64. Hope it is not overwritten in find_package or others macro
SET(FIND_LIBRARY_USE_LIB64_PATHS FALSE) SET(FIND_LIBRARY_USE_LIB64_PATHS FALSE)
#------------------------------------------------------------------------------- # Linux libraries
# FindStuff if(Linux)
#------------------------------------------------------------------------------- find_package(GTK2 REQUIRED gtk)
#---------------------------------------- find_package(X11)
# Required
#----------------------------------------
if(Linux) # Linux only
# gtk required
find_package(GTK2 REQUIRED gtk)
# gtk found
if(GTK2_FOUND)
# add gtk include directories
include_directories(${GTK2_INCLUDE_DIRS})
#else(GTK2_FOUND)
# message(FATAL_ERROR "GTK2 libraries and include files not found.
# Please install GTK2 version ${minimal_GTK2_version} or higher.")
endif(GTK2_FOUND)
endif(Linux)
#------------------------------------------------------------
# wx required
find_package(wxWidgets REQUIRED base core adv)
# wx found
if(wxWidgets_FOUND)
if(Linux) # Linux only
# Force the use of 32 bit library
STRING(REGEX REPLACE "/usr/lib/wx" "${32_LD_LIBRARY_PATH}/wx"
wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
endif(Linux)
include(${wxWidgets_USE_FILE})
#else(wxWidgets_FOUND)
# message(FATAL_ERROR "wxWidgets libraries and include files not found.\
# Please install wxWidgets version ${minimal_wxWidgets_version} \
# or higher.")
endif(wxWidgets_FOUND)
#------------------------------------------------------------
# zlib required (no require flag, because we can use project one as fallback)
find_package(ZLIB)
# if we found zlib on the system, use it else use project one
if(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB)
# add zlib include directories
include_directories(${ZLIB_INCLUDE_DIRS})
else(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB)
# use project one
set(projectZLIB TRUE)
set(ZLIB_LIBRARIES zlib)
set(ZLIB_FOUND TRUE)
endif(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB)
#------------------------------------------------------------
#----------------------------------------
# Optional
#----------------------------------------
if(Linux) # Linux only
# x11 optional
find_package(X11)
# x11 found
if(X11_FOUND)
# add x11 include directories
include_directories(${X11_INCLUDE_DIR})
#else(X11_FOUND)
# message(FATAL_ERROR "X11 libraries and include files not found.
# Please install X11.")
endif(X11_FOUND)
endif(Linux)
# Manually find Xxf86vm because it is not done in the module... # Manually find Xxf86vm because it is not done in the module...
FIND_LIBRARY(X11_Xxf86vm_LIB Xxf86vm ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xxf86vm_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
MARK_AS_ADVANCED(X11_Xxf86vm_LIB) MARK_AS_ADVANCED(X11_Xxf86vm_LIB)
endif(Linux)
#------------------------------------------------------------ # Use cmake package to find module
find_package(ALSA)
# A52 optional find_package(BZip2)
find_package(OpenGL)
# Tell cmake that we use SDL as a library and not as an application
set(SDL_BUILDING_LIBRARY TRUE)
find_package(SDL)
find_package(Subversion)
find_package(wxWidgets REQUIRED base core adv)
find_package(ZLIB)
# Use pcsx2 package to find module
include(FindA52) include(FindA52)
include(FindCg)
include(FindGlew)
include(FindPortAudio)
include(FindSoundTouch)
# if we found A52 on the system, # Note for include_directory: The order is important to avoid a mess between include file from your system and the one of pcsx2
# use it else use project one # If you include first 3rdparty, all 3rdpary include will have a higer priority...
if(A52_FOUND AND NOT FORCE_INTERNAL_A52) # If you include first /usr/include, all system include will have a higer priority over the pcsx2 one...
# add a52 include directories # Current implementation:
include_directories(${A52_INCLUDE_DIR}) # 1/ include 3rdparty sub-directory that we will used (either request or fallback)
else(A52_FOUND AND NOT FORCE_INTERNAL_A52) # 2/ include system one
# 3/ include 3rdpary main (just in case we miss some include files)
#----------------------------------------
# Fallback on 3rdparty libraries
#----------------------------------------
# Note to avoid some conflict with system include, we must include 3rdparty first
if(NOT ZLIB_FOUND OR FORCE_INTERNAL_ZLIB)
# use project one
set(projectZLIB TRUE)
set(ZLIB_FOUND TRUE)
# Set path
set(ZLIB_LIBRARIES zlib)
# XXX Need to be updated when repository will be updated
# For the moment include are done with the last fallback in bottom of the file
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/zlib)
endif(NOT ZLIB_FOUND OR FORCE_INTERNAL_ZLIB)
if(NOT BZIP2_FOUND OR FORCE_INTERNAL_BZIP2)
# use project one
set(projectBZip2 TRUE)
set(BZIP2_FOUND TRUE)
# Set path
set(BZIP2_LIBRARIES bzip2)
# XXX Need to be updated when repository will be updated
# For the moment include are done with the last fallback in bottom of the file
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/bzip)
endif(NOT BZIP2_FOUND OR FORCE_INTERNAL_BZIP2)
if(NOT SOUNDTOUCH_FOUND OR FORCE_INTERNAL_SOUNDTOUCH)
# use project one
set(projectSoundTouch TRUE)
set(SOUNDTOUCH_FOUND TRUE)
# Set path
set(SOUNDTOUCH_LIBRARIES SoundTouch)
# XXX Need to be updated when repository will be updated
# For the moment include are done with the last fallback in bottom of the file
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/soundtouch_internal)
endif(NOT SOUNDTOUCH_FOUND OR FORCE_INTERNAL_SOUNDTOUCH)
if(NOT A52_FOUND OR FORCE_INTERNAL_A52)
# use project one # use project one
set(projectA52 TRUE) set(projectA52 TRUE)
set(A52_LIBRARIES A52)
set(A52_FOUND TRUE) set(A52_FOUND TRUE)
endif(A52_FOUND AND NOT FORCE_INTERNAL_A52) # Set path
set(A52_LIBRARIES A52)
# XXX Need to be updated when repository will be updated
# For the moment include are done with the last fallback in bottom of the file
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/a52_internal)
endif(NOT A52_FOUND OR FORCE_INTERNAL_A52)
#----------------------------------------
# Use system include (if not 3rdparty one)
#----------------------------------------
if(Linux)
# GTK2
if(GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
endif(GTK2_FOUND)
# ALSA optional # x11
find_package(ALSA) if(X11_FOUND)
include_directories(${X11_INCLUDE_DIR})
endif(X11_FOUND)
endif(Linux)
# ALSA found # A52
if(A52_FOUND AND NOT projectA52)
include_directories(${A52_INCLUDE_DIR})
endif(A52_FOUND AND NOT projectA52)
# ALSA
if(ALSA_FOUND) if(ALSA_FOUND)
# add ALSA include directories
include_directories(${ALSA_INCLUDE_DIRS}) include_directories(${ALSA_INCLUDE_DIRS})
endif(ALSA_FOUND) endif(ALSA_FOUND)
#------------------------------------------------------------ # bzip2
if(BZIP2_FOUND AND NOT projectBZip2)
# bzip2 optional
find_package(BZip2)
# if we found bzip2 on the system,
# use it else use project one
if(BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2)
# add bzip include directories
include_directories(${BZIP2_INCLUDE_DIR}) include_directories(${BZIP2_INCLUDE_DIR})
else(BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2) endif(BZIP2_FOUND AND NOT projectBZip2)
# use project one
set(projectBZip2 TRUE)
set(BZIP2_LIBRARIES bzip2)
set(BZIP2_FOUND TRUE)
endif(BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2)
#------------------------------------------------------------ # Cg
# Cg optional
include(FindCg)
# found Cg
if(CG_FOUND) if(CG_FOUND)
# add Cg include directories
include_directories(${CG_INCLUDE_DIR}) include_directories(${CG_INCLUDE_DIR})
endif(CG_FOUND) endif(CG_FOUND)
#------------------------------------------------------------ # GLEW
# GLEW optional
include(FindGlew)
# found GLEW
if(GLEW_FOUND) if(GLEW_FOUND)
# add GLEW include directories
include_directories(${GLEW_INCLUDE_PATH}) include_directories(${GLEW_INCLUDE_PATH})
endif(GLEW_FOUND) endif(GLEW_FOUND)
#------------------------------------------------------------ # OpenGL
# OpenGL optional
find_package(OpenGL)
# opengl found
if(OPENGL_FOUND) if(OPENGL_FOUND)
# add OpenGL include directories
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
endif(OPENGL_FOUND) endif(OPENGL_FOUND)
#------------------------------------------------------------ # PortAudio
# PortAudio optional
include(FindPortAudio)
# found PortAudio
if(PORTAUDIO_FOUND) if(PORTAUDIO_FOUND)
# add PortAudio include directories
include_directories(${PORTAUDIO_INCLUDE_DIR}) include_directories(${PORTAUDIO_INCLUDE_DIR})
endif(PORTAUDIO_FOUND) endif(PORTAUDIO_FOUND)
#------------------------------------------------------------ # SDL
# SDL optional
set(SDL_BUILDING_LIBRARY TRUE)
find_package(SDL)
# SDL found
if(SDL_FOUND) if(SDL_FOUND)
# add SDL include directories
include_directories(${SDL_INCLUDE_DIR}) include_directories(${SDL_INCLUDE_DIR})
endif(SDL_FOUND) endif(SDL_FOUND)
#------------------------------------------------------------ # SoundTouch
if(SOUNDTOUCH_FOUND AND NOT projectSoundTouch)
# SoundTouch optional
#include(FindSoundTouch)
# found SoundTouch
if(SOUNDTOUCH_FOUND AND NOT FORCE_INTERNAL_SOUNDTOUCH)
# add SoundTouch include directories
include_directories(${SOUNDTOUCH_INCLUDE_DIR}) include_directories(${SOUNDTOUCH_INCLUDE_DIR})
else(SOUNDTOUCH_FOUND AND NOT FORCE_INTERNAL_SOUNDTOUCH) endif(SOUNDTOUCH_FOUND AND NOT projectSoundTouch)
# use project one
set(projectSoundTouch TRUE)
set(SOUNDTOUCH_LIBRARIES SoundTouch)
# found
set(SOUNDTOUCH_FOUND TRUE)
endif(SOUNDTOUCH_FOUND AND NOT FORCE_INTERNAL_SOUNDTOUCH)
#------------------------------------------------------------
# Note: subversion it only used to detect the current revision of your build
# Subversion optional # Subversion optional
find_package(Subversion)
# subversion found
if(Subversion_FOUND) if(Subversion_FOUND)
set(SVN TRUE) set(SVN TRUE)
else(Subversion_FOUND) else(Subversion_FOUND)
set(SVN FALSE) set(SVN FALSE)
endif(Subversion_FOUND) endif(Subversion_FOUND)
# Wx
if(wxWidgets_FOUND)
if(Linux)
# Force the use of 32 bit library
STRING(REGEX REPLACE "/usr/lib/wx" "${32_LD_LIBRARY_PATH}/wx"
wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
endif(Linux)
include(${wxWidgets_USE_FILE})
endif(wxWidgets_FOUND)
# Zlib
if(ZLIB_FOUND AND NOT projectZLIB)
include_directories(${ZLIB_INCLUDE_DIRS})
endif(ZLIB_FOUND AND NOT projectZLIB)
#----------------------------------------
# In all others situation fallback to the 3rdparty
#----------------------------------------
include_directories(${PROJECT_SOURCE_DIR}/3rdparty)

View File

@ -1,3 +1,42 @@
#-------------------------------------------------------------------------------
# Pcsx2 core & common libs
#-------------------------------------------------------------------------------
# Check for additional dependencies.
# If all dependencies are available, including OS, build it
#-------------------------------------------------------------------------------
#---------------------------------------
# Common libs
# requires: -wx
#---------------------------------------
if(wxWidgets_FOUND)
set(common_libs TRUE)
else(wxWidgets_FOUND)
set(common_libs FALSE)
message(STATUS "Skip build of common libraries: miss some dependencies")
endif(wxWidgets_FOUND)
#---------------------------------------
# Pcsx2 core
# requires: -wx
# -gtk2 (linux)
# -zlib
# -common_libs
#---------------------------------------
# Common dependancy
if(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
set(pcsx2_core TRUE)
else(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
set(pcsx2_core FALSE)
message(STATUS "Skip build of pcsx2 core: miss some dependencies")
endif(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
# Linux need also gtk2
if(Linux AND NOT GTK2_FOUND)
set(pcsx2_core FALSE)
message(STATUS "Skip build of pcsx2 core: miss some dependencies")
endif(Linux AND NOT GTK2_FOUND)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Plugins # Plugins
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -65,13 +104,14 @@ endif(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND)
# -OpenGL # -OpenGL
# -X11 # -X11
# -CG # -CG
# -common_libs
#--------------------------------------- #---------------------------------------
if(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) if(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND common_libs)
set(zzogl TRUE) set(zzogl TRUE)
else(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) else(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND common_libs)
set(zzogl FALSE) set(zzogl FALSE)
message(STATUS "Skip build of zzogl: miss some dependencies") message(STATUS "Skip build of zzogl: miss some dependencies")
endif(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) endif(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND common_libs)
#--------------------------------------- #---------------------------------------
#--------------------------------------- #---------------------------------------
@ -119,13 +159,14 @@ set(SPU2null TRUE)
# -ALSA # -ALSA
# -Portaudio # -Portaudio
# -A52 # -A52
# -common_libs
#--------------------------------------- #---------------------------------------
if(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND) if(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
set(spu2-x TRUE) set(spu2-x TRUE)
else(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND) else(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
set(spu2-x FALSE) set(spu2-x FALSE)
message(STATUS "Skip build of spu2-x: miss some dependencies") message(STATUS "Skip build of spu2-x: miss some dependencies")
endif(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND) endif(A52_FOUND AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
#--------------------------------------- #---------------------------------------
#--------------------------------------- #---------------------------------------