CMakeLists.txt 14.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
cmake_minimum_required(VERSION 2.6)

project(emulationstation)

#-------------------------------------------------------------------------------
#add local find scripts to CMAKE path
LIST(APPEND CMAKE_MODULE_PATH
    ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils
    ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Packages
)

#-------------------------------------------------------------------------------
#set up OpenGL system variable
set(GLSystem "Desktop OpenGL" CACHE STRING "The OpenGL system to be used")
set_property(CACHE GLSystem PROPERTY STRINGS "Desktop OpenGL" "OpenGL ES")

#-------------------------------------------------------------------------------
#check if we're running on Raspberry Pi
MESSAGE("Looking for bcm_host.h")
if(EXISTS "/opt/vc/include/bcm_host.h")
    MESSAGE("bcm_host.h found")
    set(BCMHOST found)
    set(GLSystem "OpenGL ES")
else()
    MESSAGE("bcm_host.h not found")
endif()

#finding necessary packages
#-------------------------------------------------------------------------------
if(${GLSystem} MATCHES "Desktop OpenGL")
    find_package(OpenGL REQUIRED)
else()
    find_package(OpenGLES REQUIRED)
endif()
find_package(FreeType REQUIRED)
find_package(FreeImage REQUIRED)
Aloshi's avatar
Aloshi committed
37
find_package(SDL2 REQUIRED)
38
find_package(Boost REQUIRED COMPONENTS system filesystem regex date_time)
39
find_package(Eigen3 REQUIRED)
40
find_package(CURL REQUIRED)
41

42 43 44 45 46
#add ALSA for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    find_package(ALSA REQUIRED)
endif()

47 48 49 50 51 52
#-------------------------------------------------------------------------------
#set up compiler flags and excutable names
if(DEFINED BCMHOST)
    add_definitions(-D_RPI_)
endif()

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#-------------------------------------------------------------------------------
#set up _WIN32_WINNT variable (used by boost::asio) on Windows
macro(get_WIN32_WINNT version)
    if (WIN32 AND CMAKE_SYSTEM_VERSION)
        set(ver ${CMAKE_SYSTEM_VERSION})
        string(REPLACE "." "" ver ${ver})
        string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})

        set(${version} "0x${ver}")
    endif()
endmacro()

if(WIN32)
    get_WIN32_WINNT(ver)
    add_definitions(-D_WIN32_WINNT=${ver})
endif()
#-------------------------------------------------------------------------------

71 72 73 74
if(MSVC)
    set(CMAKE_DEBUG_POSTFIX "d")
    add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
    add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
75 76
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") #multi-processor compilation
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") #multi-processor compilation
77 78 79
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
80 81 82 83
    #check for G++ 4.7+
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION)
    if (G++_VERSION VERSION_LESS 4.7)
            message(SEND_ERROR "You need at least G++ 4.7 to compile EmulationStation!")
84 85
    endif()
    #set up compiler flags for GCC
86
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes") #support C++11 for std::, optimize
87
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s")  #strip binary
88 89 90 91 92 93 94 95
endif()

if(${GLSystem} MATCHES "Desktop OpenGL")
    add_definitions(-DUSE_OPENGL_DESKTOP)
else()
    add_definitions(-DUSE_OPENGL_ES)
endif()

96 97
add_definitions(-DEIGEN_DONT_ALIGN)

98 99 100 101 102
#-------------------------------------------------------------------------------
#add include directories
set(ES_INCLUDE_DIRS
    ${FREETYPE_INCLUDE_DIRS}
    ${FreeImage_INCLUDE_DIRS}
Aloshi's avatar
Aloshi committed
103
    ${SDL2_INCLUDE_DIR}
104
    ${Boost_INCLUDE_DIRS}
105
    ${EIGEN3_INCLUDE_DIR}
106
    ${CURL_INCLUDE_DIR}
107 108
)

109 110 111 112 113 114 115
#add ALSA for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    LIST(APPEND ES_INCLUDE_DIRS
        ${ALSA_INCLUDE_DIRS}
    )
endif()

116 117 118 119 120 121 122
if(DEFINED BCMHOST)
    LIST(APPEND ES_INCLUDE_DIRS
        "/opt/vc/include"
        "/opt/vc/include/interface/vcos"
        "/opt/vc/include/interface/vmcs_host/linux"
        "/opt/vc/include/interface/vcos/pthreads"
    )
123 124 125 126 127 128 129 130 131 132
else()
    if(${GLSystem} MATCHES "Desktop OpenGL")
        LIST(APPEND ES_INCLUDE_DIRS
            ${OPENGL_INCLUDE_DIR}
        )
    else()
        LIST(APPEND ES_INCLUDE_DIRS
            ${OPENGLES_INCLUDE_DIR}
        )
    endif()
133 134 135 136 137 138
endif()

#-------------------------------------------------------------------------------
#define basic sources and headers
set(ES_HEADERS
    ${CMAKE_CURRENT_SOURCE_DIR}/src/AudioManager.h
139
    ${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.h
140
    ${CMAKE_CURRENT_SOURCE_DIR}/src/FileData.h
141
    ${CMAKE_CURRENT_SOURCE_DIR}/src/FileSorts.h
142
    ${CMAKE_CURRENT_SOURCE_DIR}/src/GuiComponent.h
143
    ${CMAKE_CURRENT_SOURCE_DIR}/src/HttpReq.h
144
	${CMAKE_CURRENT_SOURCE_DIR}/src/ImageIO.h
145 146 147 148
    ${CMAKE_CURRENT_SOURCE_DIR}/src/InputConfig.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/InputManager.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Log.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/MathExp.h
Aloshi's avatar
Aloshi committed
149
    ${CMAKE_CURRENT_SOURCE_DIR}/src/MetaData.h
150
    ${CMAKE_CURRENT_SOURCE_DIR}/src/platform.h
Aloshi's avatar
Aloshi committed
151
    ${CMAKE_CURRENT_SOURCE_DIR}/src/PlatformId.h
152
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer.h
Aloshi's avatar
Aloshi committed
153
    ${CMAKE_CURRENT_SOURCE_DIR}/src/ScraperCmdLine.h
154
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Settings.h
155 156
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.h
157
    ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.h
158
    ${CMAKE_CURRENT_SOURCE_DIR}/src/VolumeControl.h
159 160
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Window.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/XMLReader.h
161

162
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.h
163
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.h
164
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentListComponent.h
Aloshi's avatar
Aloshi committed
165
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.h
166
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.h
167
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.h
Aloshi's avatar
Aloshi committed
168
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/OptionListComponent.h
Aloshi's avatar
Aloshi committed
169
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h
170
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.h
171 172
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SliderComponent.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SwitchComponent.h
Aloshi's avatar
Aloshi committed
173
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextComponent.h
174
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.h
175
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h
176
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.h
177
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.h
Aloshi's avatar
Aloshi committed
178
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxOk.h
179
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxYesNo.h
180
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameScraper.h
181
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiInputConfig.h
182
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiSettingsMenu.h
183
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiScraperStart.h
184
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiScraperLog.h
185

186
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.h
Aloshi's avatar
Aloshi committed
187
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.h
188
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.h
189

190 191
    ${CMAKE_CURRENT_SOURCE_DIR}/src/pugiXML/pugiconfig.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/pugiXML/pugixml.hpp
192 193 194 195 196 197

    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/BasicGameListView.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/DetailedGameListView.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/GameListView.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.h

198
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Font.h
199 200
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.h
201
	${CMAKE_CURRENT_SOURCE_DIR}/data/Resources.h
202 203 204
)
set(ES_SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/src/AudioManager.cpp
205 206
    ${CMAKE_CURRENT_SOURCE_DIR}/src/FileData.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/FileSorts.cpp
207
    ${CMAKE_CURRENT_SOURCE_DIR}/src/GuiComponent.cpp
208
    ${CMAKE_CURRENT_SOURCE_DIR}/src/HttpReq.cpp
209
	${CMAKE_CURRENT_SOURCE_DIR}/src/ImageIO.cpp
210 211 212 213 214
    ${CMAKE_CURRENT_SOURCE_DIR}/src/InputConfig.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/InputManager.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Log.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/MathExp.cpp
Aloshi's avatar
Aloshi committed
215
    ${CMAKE_CURRENT_SOURCE_DIR}/src/MetaData.cpp
216 217 218
    ${CMAKE_CURRENT_SOURCE_DIR}/src/platform.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_draw_gl.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_init.cpp
Aloshi's avatar
Aloshi committed
219
    ${CMAKE_CURRENT_SOURCE_DIR}/src/ScraperCmdLine.cpp
220
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Settings.cpp
221 222
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.cpp
223
    ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.cpp
224
    ${CMAKE_CURRENT_SOURCE_DIR}/src/VolumeControl.cpp
225 226
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/XMLReader.cpp
227

228
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.cpp
229
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.cpp
230
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentListComponent.cpp
Aloshi's avatar
Aloshi committed
231
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.cpp
232
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.cpp
233
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/NinePatchComponent.cpp
Aloshi's avatar
Aloshi committed
234
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.cpp
235
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.cpp
236 237
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SliderComponent.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SwitchComponent.cpp
Aloshi's avatar
Aloshi committed
238
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextComponent.cpp
239
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.cpp
240
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.cpp
241
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.cpp
Aloshi's avatar
Aloshi committed
242
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxOk.cpp
243
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxYesNo.cpp
244
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameScraper.cpp
245
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiInputConfig.cpp
246
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiSettingsMenu.cpp
247
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiScraperStart.cpp
248
    ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiScraperLog.cpp
249

Aloshi's avatar
Aloshi committed
250
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.cpp
Aloshi's avatar
Aloshi committed
251
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.cpp
252
    ${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.cpp
253

254
    ${CMAKE_CURRENT_SOURCE_DIR}/src/pugiXML/pugixml.cpp
255
    
256
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Font.cpp
257 258
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.cpp
259

260 261 262 263 264
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/BasicGameListView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/DetailedGameListView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/GameListView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.cpp

265 266 267
    ${CMAKE_CURRENT_SOURCE_DIR}/data/ResourceUtil.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/ES_logo_16_png.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/ES_logo_32_png.cpp
268 269
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/button_png.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/frame_png.cpp
270 271
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/textbox_png.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/textbox_glow_png.cpp
Aloshi's avatar
Aloshi committed
272 273
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/star_filled_png.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/data/converted/star_unfilled_png.cpp
274 275
)

276 277
SOURCE_GROUP(resources FILES ResourceUtil.cpp)

278
#add open gl specific sources
279
#if(${GLSystem} MATCHES "Desktop OpenGL")
280 281 282
    LIST(APPEND ES_SOURCES
		${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_init_sdlgl.cpp
    )
283 284 285 286 287
#else()
#    LIST(APPEND ES_SOURCES
#		${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_init_rpi.cpp
#    )
#endif()
288

289 290 291 292 293 294 295 296
#-------------------------------------------------------------------------------
#define OS specific sources and headers
if(MSVC)
    LIST(APPEND ES_SOURCES
		${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.rc
    )
endif()

297 298
#-------------------------------------------------------------------------------
#define libraries and directories
299 300 301 302 303 304 305 306 307 308 309
if(DEFINED BCMHOST)
    link_directories(
        ${Boost_LIBRARY_DIRS}
        "/opt/vc/lib"
    )
else()
    link_directories(
        ${Boost_LIBRARY_DIRS}
    )
endif()

310
set(ES_LIBRARIES
311 312 313
    ${Boost_LIBRARIES}
    ${FREETYPE_LIBRARIES}
    ${FreeImage_LIBRARIES}
Aloshi's avatar
Aloshi committed
314 315
	${SDL2_LIBRARY}
    ${SDL2MAIN_LIBRARY}
316
    ${CURL_LIBRARIES}
317 318
)

319 320 321 322 323 324 325
#add ALSA for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    LIST(APPEND ES_LIBRARIES
        ${ALSA_LIBRARY}
    )
endif()

326 327 328
if(DEFINED BCMHOST)
    LIST(APPEND ES_LIBRARIES
        bcm_host
329
        EGL
330
        ${OPENGLES_LIBRARIES}
331
    )
332
else()
333 334 335 336 337
    if(MSVC)
        LIST(APPEND ES_LIBRARIES
            winmm
        )
    endif()
338 339 340 341 342 343 344 345 346
    if(${GLSystem} MATCHES "Desktop OpenGL")
        LIST(APPEND ES_LIBRARIES
            ${OPENGL_LIBRARIES}
        )
    else()
        LIST(APPEND ES_LIBRARIES
            ${OPENGLES_LIBRARIES}
        )
    endif()
347 348 349 350 351 352 353 354 355 356 357 358 359
endif()

#-------------------------------------------------------------------------------
#set up build directories
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)

#-------------------------------------------------------------------------------
#define target
include_directories(${ES_INCLUDE_DIRS})
add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS})
target_link_libraries(emulationstation ${ES_LIBRARIES})
360 361 362 363 364 365 366 367 368 369 370

#special properties for windows builds
if(MSVC)
    #show console in debug builds, but not in proper release builds
    #Note that up to CMake 2.8.10 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566
    set_target_properties(emulationstation PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
    set_target_properties(emulationstation PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
    set_target_properties(emulationstation PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
    set_target_properties(emulationstation PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
    set_target_properties(emulationstation PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
    set_target_properties(emulationstation PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
371
endif()