@ -2,6 +2,20 @@
# d e p e n d e n t l i b r a r i e s .
# d e p e n d e n t l i b r a r i e s .
cmake_minimum_required ( VERSION 2.8.11 )
cmake_minimum_required ( VERSION 2.8.11 )
function ( download_bundled_external remote_path lib_name prefix_var )
set ( prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}" )
if ( NOT EXISTS "${prefix}" )
message ( STATUS "Downloading binaries for ${lib_name}..." )
file ( DOWNLOAD
h t t p s : / / g i t h u b . c o m / y u r i k s / c i t r a - d e p e n d s / r a w / m a s t e r / $ { r e m o t e _ p a t h } $ { l i b _ n a m e } . 7 z
" $ { C M A K E _ B I N A R Y _ D I R } / e x t e r n a l s / $ { l i b _ n a m e } . 7 z " S H O W _ P R O G R E S S )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z"
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / e x t e r n a l s " )
endif ( )
message ( STATUS "Using bundled binaries at ${prefix}" )
set ( ${ prefix_var } "${prefix}" PARENT_SCOPE )
endfunction ( )
include ( CheckSymbolExists )
include ( CheckSymbolExists )
function ( detect_architecture symbol arch )
function ( detect_architecture symbol arch )
if ( NOT DEFINED ARCHITECTURE )
if ( NOT DEFINED ARCHITECTURE )
@ -116,59 +130,29 @@ find_package(OpenGL REQUIRED)
include_directories ( ${ OPENGL_INCLUDE_DIR } )
include_directories ( ${ OPENGL_INCLUDE_DIR } )
option ( ENABLE_GLFW "Enable the GLFW frontend" ON )
option ( ENABLE_GLFW "Enable the GLFW frontend" ON )
option ( CITRA_USE_BUNDLED_GLFW "Download bundled GLFW binaries" OFF )
if ( ENABLE_GLFW )
if ( ENABLE_GLFW )
if ( WIN32 )
if ( CITRA_USE_BUNDLED_GLFW )
# D e t e c t t o o l c h a i n a n d p l a t f o r m
# D e t e c t t o o l c h a i n a n d p l a t f o r m
if ( MSVC )
if ( MSVC14 AND ARCHITECTURE_x86_64 )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( GLFW_VER "glfw-3.1.1-msvc2015_64" )
set ( TMP_ARCH "x64" )
elseif ( MSVC12 AND ARCHITECTURE_x86_64 )
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set ( GLFW_VER "glfw-3.1.1-msvc2013_64" )
set ( TMP_ARCH "Win32" )
else ( )
else ( )
set ( TMP_ARCH "UNKNOWN" )
message ( FATAL_ERROR "No bundled GLFW binaries for your toolchain. Disable CITRA_USE_BUNDLED_GLFW and provide your own." )
message ( SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use. (Try checking CMakeOutput.log to find out why.)" )
endif ( )
endif ( )
if ( MSVC11 ) # V i s u a l C + + 2 0 1 2
if ( DEFINED GLFW_VER )
set ( TMP_TOOLSET "v110" )
download_bundled_external ( "glfw/" ${ GLFW_VER } GLFW_PREFIX )
elseif ( MSVC12 ) # V i s u a l C + + 2 0 1 3
set ( TMP_TOOLSET "v120" )
else ( )
set ( TMP_TOOLSET "UNSUPPORTED" )
message ( SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself." )
endif ( )
endif ( )
set ( TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}" )
else ( )
# A s s u m e m i n g w
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( TMP_ARCH "x86_64" )
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set ( TMP_ARCH "i686" )
else ( )
set ( TMP_ARCH "UNKNOWN" )
message ( SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use." )
endif ( )
set ( TMP_TOOLSET "mingw-${TMP_ARCH}" )
endif ( )
set ( GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.1.1.bin" )
set ( GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers" )
set ( GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers" )
set ( GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries" )
set ( GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib" CACHE PATH "Path to GLFW3 libraries" )
# C l e a n u p a f t e r o u r s e l v e s
unset ( TMP_TOOLSET )
unset ( TMP_ARCH )
set ( GLFW_LIBRARIES glfw3 )
set ( GLFW_LIBRARIES glfw3 )
else ( )
else ( )
find_package ( PkgConfig REQUIRED )
find_package ( PkgConfig REQUIRED )
pkg_search_module ( GLFW REQUIRED glfw3 )
pkg_search_module ( GLFW REQUIRED glfw3 )
endif ( )
endif ( )
include_directories ( ${ GLFW_INCLUDE_DIRS } )
link_directories ( ${ GLFW_LIBRARY_DIRS } )
endif ( )
endif ( )
IF ( APPLE )
IF ( APPLE )
@ -193,11 +177,23 @@ ELSE()
ENDIF ( APPLE )
ENDIF ( APPLE )
option ( ENABLE_QT "Enable the Qt frontend" ON )
option ( ENABLE_QT "Enable the Qt frontend" ON )
option ( CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF )
option ( CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF )
option ( CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF )
if ( ENABLE_QT )
if ( ENABLE_QT )
if ( CITRA_USE_BUNDLED_QT )
if ( MSVC14 AND ARCHITECTURE_x86_64 )
set ( QT_VER qt-5.5-msvc2015_64 )
else ( )
message ( FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own." )
endif ( )
if ( DEFINED QT_VER )
download_bundled_external ( "qt/" ${ QT_VER } QT_PREFIX )
list ( APPEND CMAKE_PREFIX_PATH "${QT_PREFIX}" )
endif ( )
elseif ( DEFINED ENV{QTDIR} )
# S e t C M A K E _ P R E F I X _ P A T H i f Q T D I R i s d e f i n e d i n t h e e n v i r o n m e n t T h i s a l l o w s C M a k e t o
# S e t C M A K E _ P R E F I X _ P A T H i f Q T D I R i s d e f i n e d i n t h e e n v i r o n m e n t T h i s a l l o w s C M a k e t o
# a u t o m a t i c a l l y f i n d t h e Q t p a c k a g e s o n W i n d o w s
# a u t o m a t i c a l l y f i n d t h e Q t p a c k a g e s o n W i n d o w s
if ( DEFINED ENV{QTDIR} )
list ( APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}" )
list ( APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}" )
endif ( )
endif ( )