2010-06-03 17:28:20 +00:00
|
|
|
### Select the build type
|
2011-10-31 10:25:24 +00:00
|
|
|
# Use Release/Devel/Debug : -DCMAKE_BUILD_TYPE=Release|Devel|Debug
|
2011-10-30 00:32:22 +00:00
|
|
|
# Enable/disable the stripping : -DCMAKE_BUILD_STRIP=TRUE|FALSE
|
2011-10-31 10:25:24 +00:00
|
|
|
# generation .po based on src : -DCMAKE_BUILD_PO=TRUE|FALSE
|
2012-05-01 10:54:52 +00:00
|
|
|
# Rebuild the ps2hw.dat file : -DREBUILD_SHADER=TRUE
|
|
|
|
# Build the Replay Loaders : -DBUILD_REPLAY_LOADERS=TRUE|FALSE
|
2011-10-30 00:32:22 +00:00
|
|
|
|
2010-06-03 17:28:20 +00:00
|
|
|
### Force the choice of 3rd party library in pcsx2 over system libraries
|
|
|
|
# Use all internal lib: -DFORCE_INTERNAL_ALL=TRUE
|
|
|
|
# Use soundtouch internal lib: -DFORCE_INTERNAL_SOUNDTOUCH=TRUE
|
|
|
|
# Use zlib internal lib: -DFORCE_INTERNAL_ZLIB=TRUE
|
2011-02-26 20:02:22 +00:00
|
|
|
# Use sdl1.3 internal lib: -DFORCE_INTERNAL_SDL=TRUE # Not supported yet
|
2012-04-19 21:22:08 +00:00
|
|
|
# Use GLSL API(else NVIDIA_CG): -DGLSL_API=TRUE
|
2011-10-30 00:32:22 +00:00
|
|
|
|
2011-07-17 11:25:17 +00:00
|
|
|
### GCC optimization options
|
2010-07-07 11:36:54 +00:00
|
|
|
# control C flags : -DUSER_CMAKE_C_FLAGS="cflags"
|
|
|
|
# control C++ flags : -DUSER_CMAKE_CXX_FLAGS="cxxflags"
|
2010-07-13 09:16:13 +00:00
|
|
|
# control link flags : -DUSER_CMAKE_LD_FLAGS="ldflags"
|
2011-10-30 00:32:22 +00:00
|
|
|
|
2011-07-17 11:25:17 +00:00
|
|
|
### Packaging options
|
|
|
|
# Installation path : -DPACKAGE_MODE=TRUE(follow FHS)|FALSE(local bin/)
|
|
|
|
# Plugin installation path : -DPLUGIN_DIR="/usr/lib/pcsx2"
|
2012-05-31 18:40:35 +00:00
|
|
|
# GL Shader installation path : -DGLSL_SHADER_DIR="/usr/share/games/pcsx2"
|
2011-07-17 11:25:17 +00:00
|
|
|
# Game DB installation path : -DGAMEINDEX_DIR="/var/games/pcsx2"
|
2011-12-21 20:27:03 +00:00
|
|
|
# Follow XDG standard : -DXDG_STD=TRUE|FALSE
|
2010-06-03 17:28:20 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2010-07-13 09:16:13 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# if no build type is set, use Devel as default
|
|
|
|
# Note without the CMAKE_BUILD_TYPE options the value is still defined to ""
|
|
|
|
# Ensure that the value set by the User is correct to avoid some bad behavior later
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Devel|Release")
|
|
|
|
set(CMAKE_BUILD_TYPE Devel)
|
|
|
|
message(STATUS "BuildType set to ${CMAKE_BUILD_TYPE} by default")
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Devel|Release")
|
|
|
|
|
|
|
|
if(NOT DEFINED CMAKE_BUILD_STRIP)
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
set(CMAKE_BUILD_STRIP TRUE)
|
|
|
|
message(STATUS "Enable the stripping by default in ${CMAKE_BUILD_TYPE} build !!!")
|
|
|
|
else(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
set(CMAKE_BUILD_STRIP FALSE)
|
|
|
|
message(STATUS "Disable the stripping by default in ${CMAKE_BUILD_TYPE} build !!!")
|
|
|
|
endif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
endif(NOT DEFINED CMAKE_BUILD_STRIP)
|
|
|
|
|
2011-10-31 10:25:24 +00:00
|
|
|
if(NOT DEFINED CMAKE_BUILD_PO)
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
set(CMAKE_BUILD_PO TRUE)
|
|
|
|
message(STATUS "Enable the building of po files by default in ${CMAKE_BUILD_TYPE} build !!!")
|
|
|
|
else(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
set(CMAKE_BUILD_PO FALSE)
|
|
|
|
message(STATUS "Disable the building of po files by default in ${CMAKE_BUILD_TYPE} build !!!")
|
|
|
|
endif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
endif(NOT DEFINED CMAKE_BUILD_PO)
|
|
|
|
|
2011-07-17 11:25:17 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Select library system vs 3rdparty
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
if(FORCE_INTERNAL_ALL)
|
|
|
|
set(FORCE_INTERNAL_SOUNDTOUCH TRUE)
|
|
|
|
set(FORCE_INTERNAL_ZLIB TRUE)
|
|
|
|
set(FORCE_INTERNAL_SDL TRUE)
|
|
|
|
endif(FORCE_INTERNAL_ALL)
|
|
|
|
|
|
|
|
if(NOT DEFINED FORCE_INTERNAL_SOUNDTOUCH)
|
2011-12-21 20:27:03 +00:00
|
|
|
set(FORCE_INTERNAL_SOUNDTOUCH FALSE)
|
2011-07-17 11:25:17 +00:00
|
|
|
endif(NOT DEFINED FORCE_INTERNAL_SOUNDTOUCH)
|
|
|
|
|
|
|
|
if(NOT DEFINED FORCE_INTERNAL_ZLIB)
|
|
|
|
set(FORCE_INTERNAL_ZLIB FALSE)
|
|
|
|
endif(NOT DEFINED FORCE_INTERNAL_ZLIB)
|
|
|
|
|
|
|
|
if(NOT DEFINED FORCE_INTERNAL_SDL)
|
|
|
|
set(FORCE_INTERNAL_SDL FALSE)
|
|
|
|
endif(NOT DEFINED FORCE_INTERNAL_SDL)
|
|
|
|
if (FORCE_INTERNAL_SDL)
|
|
|
|
message(STATUS "Internal SDL is a development snapshot of libsdl 1.3
|
|
|
|
Crashes can be expected and no support will be provided")
|
|
|
|
endif (FORCE_INTERNAL_SDL)
|
|
|
|
|
2011-12-21 20:27:03 +00:00
|
|
|
if (NOT DEFINED XDG_STD)
|
|
|
|
set(XDG_STD FALSE)
|
|
|
|
endif (NOT DEFINED XDG_STD)
|
|
|
|
|
2010-07-13 09:16:13 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Control GCC flags
|
|
|
|
#-------------------------------------------------------------------------------
|
2010-07-04 12:37:42 +00:00
|
|
|
### Cmake set default value for various compilation variable
|
|
|
|
### Here the list of default value for documentation purpose
|
|
|
|
# ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} = "-fPIC"
|
|
|
|
# ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} = "-rdynamic"
|
|
|
|
#
|
2010-07-07 11:08:05 +00:00
|
|
|
# ${CMAKE_C_FLAGS} = "-g -O2"
|
|
|
|
# ${CMAKE_CXX_FLAGS} = "-g -O2"
|
2010-07-04 12:37:42 +00:00
|
|
|
# Use in debug mode
|
|
|
|
# ${CMAKE_CXX_FLAGS_DEBUG} = "-g"
|
|
|
|
# Use in release mode
|
|
|
|
# ${CMAKE_CXX_FLAGS_RELEASE} = "-O3 -DNDEBUG"
|
|
|
|
|
2010-07-07 11:08:05 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Do not use default cmake flags
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "")
|
2010-07-07 11:36:54 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEVEL "")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEVEL "")
|
2010-07-07 11:08:05 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "")
|
|
|
|
|
2010-07-04 12:37:42 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Remove bad default option
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Remove -rdynamic option that can some segmentation fault when openining pcsx2 plugins
|
2010-07-07 11:36:54 +00:00
|
|
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
2010-07-05 15:43:21 +00:00
|
|
|
# Remove -fPIC option. No good reason to use it for plugins. Moreover we
|
|
|
|
# only support x86 architecture. And last but not least it impact the performance.
|
2010-07-07 11:08:05 +00:00
|
|
|
# Long term future note :), amd64 build will need the -fPIC flags
|
2010-07-05 15:43:21 +00:00
|
|
|
set(CMAKE_SHARED_LIBRARY_C_FLAGS "")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
|
2010-06-10 07:14:53 +00:00
|
|
|
|
2011-10-29 11:39:06 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2011-10-30 00:32:22 +00:00
|
|
|
# Set some default compiler flags
|
2011-10-29 11:39:06 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2012-05-31 18:40:35 +00:00
|
|
|
set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing -Wno-unused-function")
|
2011-10-30 00:32:22 +00:00
|
|
|
set(DEFAULT_GCC_FLAG "-m32 -msse -msse2 -march=i686 -pthread ${DEFAULT_WARNINGS}")
|
|
|
|
set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof")
|
2011-10-29 11:39:06 +00:00
|
|
|
|
2010-07-07 11:36:54 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Allow user to set some default flags
|
2010-07-13 09:16:13 +00:00
|
|
|
# Note: string STRIP must be used to remove trailing and leading spaces.
|
|
|
|
# See policy CMP0004
|
2010-07-07 11:36:54 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2010-07-13 09:16:13 +00:00
|
|
|
### linker flags
|
|
|
|
if(DEFINED USER_CMAKE_LD_FLAGS)
|
|
|
|
message(STATUS "Pcsx2 is very sensible with gcc flags, so use USER_CMAKE_LD_FLAGS at your own risk !!!")
|
|
|
|
string(STRIP "${USER_CMAKE_LD_FLAGS}" USER_CMAKE_LD_FLAGS)
|
|
|
|
else(DEFINED USER_CMAKE_LD_FLAGS)
|
|
|
|
set(USER_CMAKE_LD_FLAGS "")
|
|
|
|
endif(DEFINED USER_CMAKE_LD_FLAGS)
|
|
|
|
|
|
|
|
# ask the linker to strip the binary
|
|
|
|
if(CMAKE_BUILD_STRIP)
|
|
|
|
string(STRIP "${USER_CMAKE_LD_FLAGS} -s" USER_CMAKE_LD_FLAGS)
|
|
|
|
endif(CMAKE_BUILD_STRIP)
|
|
|
|
|
|
|
|
|
|
|
|
### c flags
|
|
|
|
# Note CMAKE_C_FLAGS is also send to the linker.
|
|
|
|
# By default allow build on amd64 machine
|
2010-07-07 11:36:54 +00:00
|
|
|
if(DEFINED USER_CMAKE_C_FLAGS)
|
|
|
|
message(STATUS "Pcsx2 is very sensible with gcc flags, so use USER_CMAKE_C_FLAGS at your own risk !!!")
|
2010-08-09 19:05:02 +00:00
|
|
|
string(STRIP "${USER_CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
2010-07-07 11:36:54 +00:00
|
|
|
endif(DEFINED USER_CMAKE_C_FLAGS)
|
2010-08-09 19:05:02 +00:00
|
|
|
# Use some default machine flags
|
2011-10-29 11:39:06 +00:00
|
|
|
string(STRIP "${CMAKE_C_FLAGS} ${DEFAULT_GCC_FLAG}" CMAKE_C_FLAGS)
|
2010-07-07 11:36:54 +00:00
|
|
|
|
2010-07-13 09:16:13 +00:00
|
|
|
|
|
|
|
### C++ flags
|
|
|
|
# Note CMAKE_CXX_FLAGS is also send to the linker.
|
|
|
|
# By default allow build on amd64 machine
|
2010-07-07 11:36:54 +00:00
|
|
|
if(DEFINED USER_CMAKE_CXX_FLAGS)
|
|
|
|
message(STATUS "Pcsx2 is very sensible with gcc flags, so use USER_CMAKE_CXX_FLAGS at your own risk !!!")
|
2010-07-13 09:16:13 +00:00
|
|
|
string(STRIP "${USER_CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
2010-07-07 11:36:54 +00:00
|
|
|
endif(DEFINED USER_CMAKE_CXX_FLAGS)
|
2010-08-09 19:05:02 +00:00
|
|
|
# Use some default machine flags
|
2011-10-30 00:32:22 +00:00
|
|
|
string(STRIP "${CMAKE_CXX_FLAGS} ${DEFAULT_CPP_FLAG}" CMAKE_CXX_FLAGS)
|
2010-07-07 11:36:54 +00:00
|
|
|
|
2011-02-12 10:37:44 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2011-07-17 11:25:17 +00:00
|
|
|
# Default package option
|
2011-02-12 10:37:44 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
if(NOT DEFINED PACKAGE_MODE)
|
|
|
|
set(PACKAGE_MODE FALSE)
|
|
|
|
endif(NOT DEFINED PACKAGE_MODE)
|
|
|
|
|
2011-07-17 11:25:17 +00:00
|
|
|
if(PACKAGE_MODE)
|
|
|
|
if(NOT DEFINED PLUGIN_DIR)
|
|
|
|
set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/lib/games/pcsx2")
|
|
|
|
endif(NOT DEFINED PLUGIN_DIR)
|
2010-06-03 17:28:20 +00:00
|
|
|
|
2011-07-17 11:25:17 +00:00
|
|
|
if(NOT DEFINED GAMEINDEX_DIR)
|
|
|
|
set(GAMEINDEX_DIR "/var/games/pcsx2")
|
|
|
|
endif(NOT DEFINED GAMEINDEX_DIR)
|
2011-01-22 12:10:46 +00:00
|
|
|
|
2012-05-31 18:40:35 +00:00
|
|
|
if(NOT DEFINED GLSL_SHADER_DIR)
|
|
|
|
set(GLSL_SHADER_DIR "/usr/share/games/pcsx2")
|
|
|
|
endif(NOT DEFINED GLSL_SHADER_DIR)
|
|
|
|
|
|
|
|
# Compile all source codes with these 3 defines
|
2011-07-17 11:25:17 +00:00
|
|
|
add_definitions(-DPLUGIN_DIR_COMPILATION=${PLUGIN_DIR} -DGAMEINDEX_DIR_COMPILATION=${GAMEINDEX_DIR})
|
2012-05-31 18:40:35 +00:00
|
|
|
add_definitions(-DGLSL_SHADER_DIR_COMPILATION=${GLSL_SHADER_DIR})
|
2011-07-17 11:25:17 +00:00
|
|
|
endif(PACKAGE_MODE)
|
2012-04-19 21:22:08 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Select nvidia cg shader api by default
|
|
|
|
#-------------------------------------------------------------------------------
|
2012-04-20 16:48:03 +00:00
|
|
|
if(NOT DEFINED GLSL_API)
|
2012-04-19 21:22:08 +00:00
|
|
|
set(GLSL_API FALSE)
|
2012-04-20 16:48:03 +00:00
|
|
|
endif(NOT DEFINED GLSL_API)
|
2012-05-01 10:54:52 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Use the precompiled shader file by default
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
if(NOT DEFINED REBUILD_SHADER)
|
|
|
|
set(REBUILD_SHADER FALSE)
|
|
|
|
endif(NOT DEFINED REBUILD_SHADER)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Build the replay loaders by default
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
if(NOT DEFINED BUILD_REPLAY_LOADERS)
|
|
|
|
set(BUILD_REPLAY_LOADERS TRUE)
|
|
|
|
endif(NOT DEFINED BUILD_REPLAY_LOADERS)
|