summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt180
1 files changed, 94 insertions, 86 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 121b0f2f8..1f0af2d41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,20 +1,25 @@
-# CMake 3.2 required for cmake to know the right flags for CXX standard on OSX
-cmake_minimum_required(VERSION 3.2)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
+# CMake 3.6 required for FindBoost to define IMPORTED libs properly on unknown Boost versions
+cmake_minimum_required(VERSION 3.6)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
-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
- https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z
- "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS)
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z"
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
- endif()
- message(STATUS "Using bundled binaries at ${prefix}")
- set(${prefix_var} "${prefix}" PARENT_SCOPE)
-endfunction()
+project(citra)
+
+option(ENABLE_SDL2 "Enable the SDL2 frontend" ON)
+option(CITRA_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
+
+option(ENABLE_QT "Enable the Qt frontend" ON)
+option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit)
+ message(STATUS "Copying pre-commit hook")
+ file(COPY hooks/pre-commit
+ DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks)
+endif()
+
+
+# Detect current compilation architecture and create standard definitions
+# =======================================================================
include(CheckSymbolExists)
function(detect_architecture symbol arch)
@@ -33,20 +38,6 @@ function(detect_architecture symbol arch)
endif()
endfunction()
-project(citra)
-
-option(ENABLE_SDL2 "Enable the SDL2 frontend" ON)
-option(CITRA_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
-
-option(ENABLE_QT "Enable the Qt frontend" ON)
-option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
-
-if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
- message(STATUS "Copying pre-commit hook")
- file(COPY hooks/pre-commit
- DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks)
-endif()
-
if (MSVC)
detect_architecture("_M_AMD64" x86_64)
detect_architecture("_M_IX86" x86)
@@ -63,6 +54,10 @@ if (NOT DEFINED ARCHITECTURE)
endif()
message(STATUS "Target architecture: ${ARCHITECTURE}")
+
+# Configure compilation flags
+# ===========================
+
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -130,28 +125,44 @@ add_definitions(-DSINGLETHREADED)
set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
+
+# System imported libraries
+# ======================
+
+# This function downloads a binary library package from our external repo.
+# Params:
+# remote_path: path to the file to download, relative to the remote repository root
+# prefix_var: name of a variable which will be set with the path to the extracted contents
+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
+ https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z
+ "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
+ endif()
+ message(STATUS "Using bundled binaries at ${prefix}")
+ set(${prefix_var} "${prefix}" PARENT_SCOPE)
+endfunction()
+
find_package(PNG QUIET)
-if (PNG_FOUND)
- add_definitions(-DHAVE_PNG)
-else()
+if (NOT PNG_FOUND)
message(STATUS "libpng not found. Some debugging features have been disabled.")
endif()
-find_package(Boost 1.57.0 QUIET)
+find_package(Boost 1.63.0 QUIET)
if (NOT Boost_FOUND)
- message(STATUS "Boost 1.57.0 or newer not found, falling back to externals")
- set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost")
-endif()
-include_directories(${Boost_INCLUDE_DIR})
-
-# Include bundled CMake modules
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
+ message(STATUS "Boost 1.63.0 or newer not found, falling back to externals")
-find_package(OpenGL REQUIRED)
-include_directories(${OPENGL_INCLUDE_DIR})
+ set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/externals/boost")
+ set(Boost_NO_SYSTEM_PATHS OFF)
+ find_package(Boost QUIET REQUIRED)
+endif()
# Prefer the -pthread flag on Linux.
-set (THREADS_PREFER_PTHREAD_FLAG ON)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (ENABLE_SDL2)
@@ -174,10 +185,43 @@ if (ENABLE_SDL2)
else()
find_package(SDL2 REQUIRED)
endif()
+
+ if (SDL2_FOUND)
+ # TODO(yuriks): Make FindSDL2.cmake export an IMPORTED library instead
+ add_library(SDL2 INTERFACE)
+ target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}")
+ target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}")
+ endif()
else()
set(SDL2_FOUND NO)
endif()
+if (ENABLE_QT)
+ if (CITRA_USE_BUNDLED_QT)
+ if (MSVC14 AND ARCHITECTURE_x86_64)
+ set(QT_VER qt-5.7-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)
+ endif()
+
+ set(QT_PREFIX_HINT HINTS "${QT_PREFIX}")
+ else()
+ # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so
+ # make sure to not pass anything if we don't have one.
+ set(QT_PREFIX_HINT)
+ endif()
+
+ find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT})
+endif()
+
+
+# Platform-specific library requirements
+# ======================================
+
IF (APPLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa) # Umbrella framework for everything GUI-related
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
@@ -206,28 +250,9 @@ if (UNIX OR MINGW)
endif()
endif()
-if (ENABLE_QT)
- if (CITRA_USE_BUNDLED_QT)
- if (MSVC14 AND ARCHITECTURE_x86_64)
- set(QT_VER qt-5.7-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)
- endif()
- set(QT_PREFIX_HINT HINTS "${QT_PREFIX}")
- else()
- # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so
- # make sure to not pass anything if we don't have one.
- set(QT_PREFIX_HINT)
- endif()
-
- find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT})
- set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL)
-endif()
+# Include source code
+# ===================
# This function should be passed a list of all files in a target. It will automatically generate
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
@@ -251,30 +276,13 @@ get_git_head_revision(GIT_REF_SPEC GIT_REV)
git_describe(GIT_DESC --always --long --dirty)
git_branch_name(GIT_BRANCH)
-set(INI_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/inih")
-include_directories(${INI_PREFIX})
-add_subdirectory(${INI_PREFIX})
-
add_subdirectory(externals)
-
-option(DYNARMIC_TESTS OFF)
-set(DYNARMIC_NO_BUNDLED_FMT ON)
-add_subdirectory(externals/dynarmic)
-
-add_subdirectory(externals/glad)
-include_directories(externals/microprofile)
-include_directories(externals/nihstro/include)
-
-if (MSVC)
- add_subdirectory(externals/getopt)
-endif()
-
-# process subdirectories
-add_subdirectory(externals/soundtouch)
-
+add_subdirectory(src)
enable_testing()
-add_subdirectory(src)
+
+# Installation instructions
+# =========================
# Install freedesktop.org metadata files, following those specifications:
# http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html