2014-06-20 01:30:09 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2013-05-14 19:40:21 +00:00
|
|
|
|
|
|
|
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()
|
2013-12-15 00:52:12 +00:00
|
|
|
find_package(Freetype REQUIRED)
|
2013-05-14 19:40:21 +00:00
|
|
|
find_package(FreeImage REQUIRED)
|
2013-08-18 17:17:24 +00:00
|
|
|
find_package(SDL2 REQUIRED)
|
2014-04-16 17:32:40 +00:00
|
|
|
find_package(Boost REQUIRED COMPONENTS system filesystem date_time)
|
2013-07-11 08:47:49 +00:00
|
|
|
find_package(Eigen3 REQUIRED)
|
2013-10-10 18:11:01 +00:00
|
|
|
find_package(CURL REQUIRED)
|
2013-05-14 19:40:21 +00:00
|
|
|
|
2013-05-22 17:11:10 +00:00
|
|
|
#add ALSA for Linux
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
find_package(ALSA REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2013-05-14 19:40:21 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#set up compiler flags and excutable names
|
|
|
|
if(DEFINED BCMHOST)
|
|
|
|
add_definitions(-D_RPI_)
|
|
|
|
endif()
|
|
|
|
|
2013-09-15 17:56:47 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2013-05-14 19:40:21 +00:00
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_DEBUG_POSTFIX "d")
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
2013-05-17 09:58:43 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") #multi-processor compilation
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") #multi-processor compilation
|
2013-05-14 19:40:21 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
2013-05-24 09:36:29 +00:00
|
|
|
#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!")
|
2013-05-22 17:15:44 +00:00
|
|
|
endif()
|
2014-06-20 01:30:09 +00:00
|
|
|
|
2013-05-22 17:15:44 +00:00
|
|
|
#set up compiler flags for GCC
|
2014-04-12 20:14:40 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -O3") #support C++11 for std::, optimize
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O3") #-s = strip binary
|
2013-05-14 19:40:21 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${GLSystem} MATCHES "Desktop OpenGL")
|
|
|
|
add_definitions(-DUSE_OPENGL_DESKTOP)
|
|
|
|
else()
|
|
|
|
add_definitions(-DUSE_OPENGL_ES)
|
|
|
|
endif()
|
|
|
|
|
2013-07-10 11:32:51 +00:00
|
|
|
add_definitions(-DEIGEN_DONT_ALIGN)
|
|
|
|
|
2013-05-14 19:40:21 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#add include directories
|
2014-06-20 01:30:09 +00:00
|
|
|
set(COMMON_INCLUDE_DIRS
|
2013-05-14 19:40:21 +00:00
|
|
|
${FREETYPE_INCLUDE_DIRS}
|
|
|
|
${FreeImage_INCLUDE_DIRS}
|
2013-08-18 17:17:24 +00:00
|
|
|
${SDL2_INCLUDE_DIR}
|
2013-05-14 19:40:21 +00:00
|
|
|
${Boost_INCLUDE_DIRS}
|
2013-07-11 08:47:49 +00:00
|
|
|
${EIGEN3_INCLUDE_DIR}
|
2013-10-10 18:11:01 +00:00
|
|
|
${CURL_INCLUDE_DIR}
|
2014-06-20 01:30:09 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/external
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/core/src
|
2013-05-14 19:40:21 +00:00
|
|
|
)
|
|
|
|
|
2013-05-22 17:11:10 +00:00
|
|
|
#add ALSA for Linux
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_INCLUDE_DIRS
|
2013-05-22 17:11:10 +00:00
|
|
|
${ALSA_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-05-14 19:40:21 +00:00
|
|
|
if(DEFINED BCMHOST)
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_INCLUDE_DIRS
|
2013-05-14 19:40:21 +00:00
|
|
|
"/opt/vc/include"
|
|
|
|
"/opt/vc/include/interface/vcos"
|
|
|
|
"/opt/vc/include/interface/vmcs_host/linux"
|
|
|
|
"/opt/vc/include/interface/vcos/pthreads"
|
|
|
|
)
|
2013-05-15 07:50:59 +00:00
|
|
|
else()
|
|
|
|
if(${GLSystem} MATCHES "Desktop OpenGL")
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_INCLUDE_DIRS
|
2013-05-15 07:50:59 +00:00
|
|
|
${OPENGL_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
else()
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_INCLUDE_DIRS
|
2013-05-15 07:50:59 +00:00
|
|
|
${OPENGLES_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
2013-05-14 19:40:21 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#define libraries and directories
|
2013-05-16 10:04:02 +00:00
|
|
|
if(DEFINED BCMHOST)
|
|
|
|
link_directories(
|
|
|
|
${Boost_LIBRARY_DIRS}
|
|
|
|
"/opt/vc/lib"
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
link_directories(
|
|
|
|
${Boost_LIBRARY_DIRS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
set(COMMON_LIBRARIES
|
2013-05-16 10:04:02 +00:00
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${FREETYPE_LIBRARIES}
|
|
|
|
${FreeImage_LIBRARIES}
|
2013-08-18 17:17:24 +00:00
|
|
|
${SDL2_LIBRARY}
|
|
|
|
${SDL2MAIN_LIBRARY}
|
2013-10-10 18:11:01 +00:00
|
|
|
${CURL_LIBRARIES}
|
2014-06-20 01:30:09 +00:00
|
|
|
pugixml
|
|
|
|
nanosvg
|
2013-05-14 19:40:21 +00:00
|
|
|
)
|
|
|
|
|
2013-05-22 17:11:10 +00:00
|
|
|
#add ALSA for Linux
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_LIBRARIES
|
2013-05-22 17:11:10 +00:00
|
|
|
${ALSA_LIBRARY}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-05-14 19:40:21 +00:00
|
|
|
if(DEFINED BCMHOST)
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_LIBRARIES
|
2013-05-14 19:40:21 +00:00
|
|
|
bcm_host
|
2013-05-15 07:50:59 +00:00
|
|
|
EGL
|
2013-05-24 09:36:29 +00:00
|
|
|
${OPENGLES_LIBRARIES}
|
2013-05-14 19:40:21 +00:00
|
|
|
)
|
2013-05-15 07:50:59 +00:00
|
|
|
else()
|
2013-05-22 17:11:10 +00:00
|
|
|
if(MSVC)
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_LIBRARIES
|
2013-05-22 17:11:10 +00:00
|
|
|
winmm
|
|
|
|
)
|
|
|
|
endif()
|
2013-05-15 07:50:59 +00:00
|
|
|
if(${GLSystem} MATCHES "Desktop OpenGL")
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_LIBRARIES
|
2013-05-15 07:50:59 +00:00
|
|
|
${OPENGL_LIBRARIES}
|
|
|
|
)
|
|
|
|
else()
|
2014-06-20 01:30:09 +00:00
|
|
|
LIST(APPEND COMMON_LIBRARIES
|
2013-05-15 07:50:59 +00:00
|
|
|
${OPENGLES_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
2013-05-14 19:40:21 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2014-06-20 01:30:09 +00:00
|
|
|
# set up build directories
|
2013-05-14 19:40:21 +00:00
|
|
|
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)
|
|
|
|
|
2014-06-03 18:57:44 +00:00
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# add each component
|
2014-06-03 01:33:59 +00:00
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
add_subdirectory("external")
|
|
|
|
add_subdirectory("core")
|
|
|
|
add_subdirectory("es")
|