DX9/DX11: Remove some dead or obsolete code.
[dolphin.git] / CMakeLists.txt
blobc3cdad79a59173c59ee48573ea7fa04ae75cace6
1 ########################################
2 # General setup
4 cmake_minimum_required(VERSION 2.6)
5 project(dolphin-emu)
6 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
8 set(DOLPHIN_IS_STABLE FALSE)
9 set(prefix              ${CMAKE_INSTALL_PREFIX}                                         CACHE PATH "prefix")
10 set(bindir              ${CMAKE_INSTALL_PREFIX}/bin                                     CACHE PATH "bindir")
11 set(libdir              ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}        CACHE PATH "libdir")
12 set(plugindir   ${libdir}/dolphin-emu                                           CACHE PATH "plugindir")
13 set(datadir             ${CMAKE_INSTALL_PREFIX}/share/dolphin-emu       CACHE PATH "datadir")
15 # Set up paths
16 set(userdir ".dolphin-emu" CACHE STRING "User directory")
17 add_definitions(-DUSER_DIR="${userdir}")
18 add_definitions(-DDATA_DIR="${datadir}/")
19 add_definitions(-DLIBS_DIR="${plugindir}/")
21 # These just set where the binary files will be built.  The program will not
22 # execute from here.  You must run "make install" to install these to the
23 # proper location as defined above.
24 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)
25 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries/plugins)
27 include(FindSubversion OPTIONAL) # for revision info
28 if(Subversion_FOUND)
29         Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} DOLPHIN) # defines DOLPHIN_WC_REVISION
30 endif()
32 # TODO: Make this optional or even implement our own package detection
33 include(FindPkgConfig REQUIRED)
35 # Various compile flags
36 add_definitions(-msse2 -Wall)
38 # gcc uses some optimizations which might break stuff without this flag
39 add_definitions(-fno-strict-aliasing)
41 include(CheckCXXCompilerFlag)
42 CHECK_CXX_COMPILER_FLAG(-fvisibility-inlines-hidden VISIBILITY_INLINES_HIDDEN)
43 if(VISIBILITY_INLINES_HIDDEN)
44         set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden)
45 endif(VISIBILITY_INLINES_HIDDEN)
47 CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden VISIBILITY_HIDDEN)
48 if(VISIBILITY_HIDDEN)
49         add_definitions(-fvisibility=hidden)
50 endif(VISIBILITY_HIDDEN)
52 add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
54 if(NOT CMAKE_BUILD_TYPE)
55         set(CMAKE_BUILD_TYPE "Release" CACHE STRING
56                 "Build type (Release/Debug/RelWithDebInfo/MinSizeRe)" FORCE)
57 endif(NOT CMAKE_BUILD_TYPE)
59 if(CMAKE_BUILD_TYPE STREQUAL Debug)
60         add_definitions(-D_DEBUG -ggdb)
61         set(wxWidgets_USE_DEBUG ON CACHE BOOL "Use wxWidgets Debugging")
62 endif(CMAKE_BUILD_TYPE STREQUAL Debug)
64 if(CMAKE_BUILD_TYPE STREQUAL Release)
65         add_definitions(-fomit-frame-pointer)
66 endif(CMAKE_BUILD_TYPE STREQUAL Release)
68 ########################################
69 # Dependency checking
71 # NOTES:
72 # There are numerous possible cases:
73 # - dependency may be required or optional
74 # - dependency may be already installed (but optionally the bundled one may be used)
75
76 # TODO: We should have a number of options for optional dependencies (disable,
77 # force bundled, bundled or native, force native).  For example the OpenGL
78 # plugin defaults to force native, so we error out if no GL libs are found.
79 # The user is free to explicitely disable it though.  Stuff which is likely to
80 # be needed by users is made an option with default ON, other stuff (like e.g.
81 # sound backends) is made completely optionally.
83 # TODO: wxWidgets: When building the Debug configuration, we should probably
84 # check if the debug wx libs are available and fall back to the bundled ones
85 # otherwise.
87 include(FindOpenGL REQUIRED)
89 include(FindALSA OPTIONAL)
90 include(FindOpenAL OPTIONAL)
91 include(FindwxWidgets OPTIONAL)
92 if(UNIX)
93         include(FindX11 REQUIRED)
94 endif(UNIX)
96 pkg_search_module(PULSEAUDIO libpulse)
97 pkg_search_module(AO ao)
98 pkg_search_module(BLUEZ bluez)
99 pkg_search_module(XRANDR xrandr)
101 # TODO: Make some of these optional like explained above
102 if(ALSA_FOUND)
103         add_definitions(-DHAVE_ALSA=1)
104         message("ALSA found, enabling ALSA sound backend")
105 else()
106         add_definitions(-DHAVE_ALSA=0)
107         message("ALSA NOT found, disabling ALSA sound backend")
108 endif(ALSA_FOUND)
110 if(AO_FOUND)
111         add_definitions(-DHAVE_AO=1)
112         include_directories(${AO_INCLUDE_DIRS})
113         message("ao found, enabling ao sound backend")
114 else()
115         add_definitions(-DHAVE_AO=0)
116         message("ao NOT found, disabling ao sound backend")
117 endif(AO_FOUND)
119 if(BLUEZ_FOUND)
120         add_definitions(-DHAVE_BLUEZ=1)
121         include_directories(${BLUEZ_INCLUDE_DIRS})
122         message("bluez found, enabling bluetooth support")
123 else()
124         add_definitions(-DHAVE_BLUEZ=0)
125         message("bluez NOT found, enabling bluetooth support")
126 endif(BLUEZ_FOUND)
128 include_directories(${OPENGL_INCLUDE_DIR})
130 if(PULSEAUDIO_FOUND)
131         add_definitions(-DHAVE_PULSEAUDIO=1)
132         include_directories(${PULSEAUDIO_INCLUDE_DIR})
133         message("PulseAudio found, enabling PulseAudio sound backend")
134 else()
135         add_definitions(-DHAVE_PULSEAUDIO=0)
136         message("PulseAudio NOT found, disabling PulseAudio sound backend")
137 endif(PULSEAUDIO_FOUND)
139 if(OPENAL_FOUND)
140         add_definitions(-DHAVE_OPENAL=1)
141         include_directories(${OPENAL_INCLUDE_DIR})
142         message("OpenAL found, enabling OpenAL sound backend")
143 else()
144         add_definitions(-DHAVE_OPENAL=0)
145         message("OpenAL NOT found, disabling OpenAL sound backend")
146 endif(OPENAL_FOUND)
148 if(wxWidgets_FOUND)
149         add_definitions(-DHAVE_WX=1)
150         include(${wxWidgets_USE_FILE})
152         if(UNIX)
153                 pkg_search_module(GTK2 REQUIRED gtk+-2.0)
154                 if(GTK2_FOUND)
155                         include_directories(${GTK2_INCLUDE_DIRS})
156                         message("GTK 2 found")
157                 else(GTK2_FOUND)
158                         message("GTK 2 NOT found")
159                 endif(GTK2_FOUND)
160         endif(UNIX)
162         message("wxWidgets found, enabling GUI build")
163 else(wxWidgets_FOUND)
164         add_definitions(-DHAVE_WX=0)
165         message("wxWidgets NOT found, disabling GUI build (using CLI interface)")
166 endif(wxWidgets_FOUND)
168 if(X11_FOUND)
169         add_definitions(-DHAVE_X11=1)
170         include_directories(${X11_INCLUDE_DIR})
171         message("X11 found")
172 else()
173         add_definitions(-DHAVE_X11=0)
174         message("X11 NOT found")
175 endif(X11_FOUND)
177 if(XRANDR_FOUND)
178         add_definitions(-DHAVE_XRANDR=1)
179         message("Xrandr found")
180 else()
181         add_definitions(-DHAVE_XRANDR=0)
182         message("Xrandr NOT found")
183 endif(XRANDR_FOUND)
185 find_library(PORTAUDIO portaudio)
186 if(PORTAUDIO)
187         include(CheckFunctionExists)
188         set(CMAKE_REQUIRED_LIBRARIES portaudio)
189         CHECK_FUNCTION_EXISTS(Pa_GetVersion PORTAUDIO_VERSION_CHECK)
190 endif(PORTAUDIO)
191 if(PORTAUDIO AND PORTAUDIO_VERSION_CHECK)
192         message("PortAudio found, enabling mic support")
193         add_definitions(-DHAVE_PORTAUDIO=1)
194         set(PORTAUDIO_FOUND TRUE)
195 else()
196         message("PortAudio not found, disabling mic support")
197         add_definitions(-DHAVE_PORTAUDIO=0)
198         set(PORTAUDIO_FOUND FALSE)
199 endif(PORTAUDIO AND PORTAUDIO_VERSION_CHECK)
201 find_library(OPENCL OpenCL)
202 find_path(OPENCL_INCLUDE CL/cl.h)
203 if(OPENCL AND OPENCL_INCLUDE)
204         message("OpenCL found")
205         add_definitions(-DHAVE_OPENCL=1)
206         include_directories(${OPENCL_INCLUDE})
207         set(OPENCL_FOUND TRUE)
208 else()
209         message("OpenCL not found")
210         add_definitions(-DHAVE_OPENCL=0)
211         set(OPENCL_FOUND FALSE)
212 endif(OPENCL AND OPENCL_INCLUDE)
215 ########################################
216 # Setup include directories (and make sure they are preferred over the Externals)
218 include_directories(Source/PluginSpecs)
219 include_directories(Externals)
220 include_directories(Source/Core/AudioCommon/Src)
221 include_directories(Source/Core/Common/Src)
222 include_directories(Source/Core/Core/Src)
223 include_directories(Source/Core/DebuggerUICommon/Src)
224 include_directories(Source/Core/DebuggerWX/Src)
225 include_directories(Source/Core/DiscIO/Src)
226 include_directories(Source/Core/DolphinWX/Src)
227 include_directories(Source/Core/DSPCore/Src)
228 include_directories(Source/Core/InputCommon/Src)
229 include_directories(Source/Core/InputUICommon/Src)
230 include_directories(Source/Core/VideoCommon/Src)
233 ########################################
234 # Process externals and setup their include directories
236 # NOTES about adding Externals:
237 #   - add the include directory here
238 #   - make sure to tell cmake to link them statically or dynamically (most
239 #     should be linked statically)
240 #   - place the CMakeLists.txt in the first-level subdirectory, e.g.
241 #     Externals/WiiUse/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
243 add_subdirectory(Externals/Bochs_disasm)
244 include_directories(Externals/Bochs_disasm)
246 # TODO: Try using the native lib first
247 # To use the native lib for Lua the dolphin code will need to be changed.
248 # Currently the file lstate.h is improperly included.
249 add_subdirectory(Externals/Lua)
250 include_directories(Externals/Lua)
252 find_library(LZO lzo2)
253 find_path(LZO_INCLUDE lzo/lzo1x.h)
254 if(LZO AND LZO_INCLUDE)
255         message("Using shared lzo")
256         include_directories(${LZO_INCLUDE})
257 else()
258         message("Shared lzo not found, falling back to the static library")
259         add_subdirectory(Externals/LZO)
260         include_directories(Externals/LZO)
261 endif(LZO AND LZO_INCLUDE)
263 include(FindSDL OPTIONAL)
264 if(SDL_FOUND)
265         message("Using shared SDL")
266         include_directories(${SDL_INCLUDE_DIR})
267 else(SDL_FOUND)
268         # TODO: No CMakeLists.txt there, yet...
269         message("Shared SDL not found, falling back to the static library")
270         add_subdirectory(Externals/SDL)
271         include_directories(Externals/SDL/include)
272 endif(SDL_FOUND)
274 find_library(SFML_NETWORK sfml-network)
275 find_path(SFML_INCLUDE SFML/Network/Ftp.hpp)
276 if(SFML_NETWORK AND SFML_INCLUDE)
277         message("Using shared sfml-network")
278         include_directories(${SFML_INCLUDE})
279 else()
280         message("Shared sfml-network not found, falling back to the static library")
281         add_subdirectory(Externals/SFML)
282         include_directories(Externals/SFML/include)
283 endif(SFML_NETWORK AND SFML_INCLUDE)
285 find_library(SOIL SOIL)
286 find_path(SOIL_INCLUDE SOIL/SOIL.h)
287 if(SOIL AND SOIL_INCLUDE)
288         message("Using shared SOIL")
289         include_directories(${SOIL_INCLUDE})
290 else()
291         message("Shared SOIL not found, falling back to the static library")
292         add_subdirectory(Externals/SOIL)
293         include_directories(Externals/SOIL)
294 endif(SOIL AND SOIL_INCLUDE)
296 include(FindZLIB OPTIONAL) # TODO: Move to top
297 if(ZLIB_FOUND)
298         include_directories(${ZLIB_INCLUDE_DIRS})
299 else(ZLIB_FOUND)
300         # TODO: No CMakeLists.txt there, yet...
301         add_subdirectory(Externals/zlib)
302         include_directories(Externals/zlib)
303 endif(ZLIB_FOUND)
305 add_subdirectory(Externals/WiiUse)
306 include_directories(Externals/WiiUse/Src)
309 ########################################
310 # Pre-build events: Define configuration variables and write svnrev header
312 file(WRITE ./Source/Core/Common/Src/svnrev.h
313         "#define SVN_REV_STR \"" ${DOLPHIN_WC_REVISION} "-" ${CMAKE_BUILD_TYPE} "\"")
316 ########################################
317 # Start compiling our code
319 add_subdirectory(Source)
322 ########################################
323 # Install shared data files
325 install(DIRECTORY Data/User/ DESTINATION ${datadir}/user PATTERN .svn EXCLUDE)
326 install(DIRECTORY Data/Sys/ DESTINATION ${datadir}/sys PATTERN .svn EXCLUDE)
327 install(FILES Data/license.txt DESTINATION ${datadir})
329 # packaging information
330 include(CPack)
331 set(CPACK_PACKAGE_NAME "dolphin-emu")
332 set(CPACK_PACKAGE_VENDOR "Dolphin Team")
333 set(CPACK_PACKAGE_VERSION_MAJOR "2")
334 set(CPACK_PACKAGE_VERSION_MINOR "0")
336 if(DOLPHIN_IS_STABLE)
337         set(CPACK_PACKAGE_VERSION_PATCH "0")
338 else()
339         set(CPACK_PACKAGE_VERSION_PATCH ${DOLPHIN_WC_REV})
340 endif()
342 # TODO: CPACK_PACKAGE_DESCRIPTION_FILE
343 # TODO: CPACK_PACKAGE_DESCRIPTION_SUMMARY
344 # TODO: CPACK_RESOURCE_FILE_README
345 # TODO: CPACK_RESOURCE_FILE_WELCOME
346 # TODO: CPACK_PACKAGE_EXECUTABLES
347 # TODO: CPACK_PACKAGE_ICON
348 # TODO: CPACK_NSIS_*
349 # TODO: Use CPack components for DSPSpy, etc => cpack_add_component