forked from decaf-emu/decaf-emu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (99 loc) · 3.79 KB
/
CMakeLists.txt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.2)
project(decaf-emu C CXX)
option(DECAF_BUILD_TESTS "Build tests" OFF)
option(DECAF_BUILD_TOOLS "Build tools" OFF)
option(DECAF_BUILD_WUT_TESTS "Build tests which rely on wut" OFF)
option(DECAF_JIT_ALLOW_PROFILING "Build with JIT profiling support" ON)
option(DECAF_FFMPEG "Build with ffmpeg support" OFF)
option(DECAF_GL "Build with OpenGL rendering support" ON)
option(DECAF_SDL "Build with SDL support" ON)
option(DECAF_VALGRIND "Build with Valgrind support" OFF)
option(DECAF_VULKAN "Build with Vulkan rendering support" OFF)
option(DECAF_QT "Build with Qt support" OFF)
set(DEVKITPPC $ENV{DEVKITPPC} CACHE STRING "Path to devkitPPC install")
set(WUT_ROOT $ENV{WUT_ROOT} CACHE STRING "Path to wut install")
if(DECAF_BUILD_WUT_TESTS AND (NOT DEVKITPPC OR NOT WUT_ROOT))
message(FATAL_ERROR "You must have defined DEVKITPPC and WUT_ROOT to build wut tests.")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/obj)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/obj)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/obj)
find_package(Threads REQUIRED)
if(DECAF_JIT_ALLOW_PROFILING)
add_definitions(-DDECAF_JIT_ALLOW_PROFILING)
endif()
if(DECAF_FFMPEG)
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
find_library(AVCODEC_LIBRARY avcodec)
find_path(AVFILTER_INCLUDE_DIR libavfilter/avfilter.h)
find_library(AVFILTER_LIBRARY avfilter)
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h)
find_library(AVUTIL_LIBRARY avutil)
find_path(SWSCALE_INCLUDE_DIR libswscale/swscale.h)
find_library(SWSCALE_LIBRARY swscale)
add_definitions(-DDECAF_FFMPEG)
endif()
if(DECAF_GL)
if(APPLE)
message(FATAL_ERROR "The OpenGL backend is not supported on macOS. Please use -DDECAF_GL=OFF to suppress this error.")
endif()
find_package(OpenGL REQUIRED)
add_definitions(-DDECAF_GL)
endif()
if(DECAF_SDL)
add_definitions(-DDECAF_SDL)
endif()
if(DECAF_VULKAN)
find_package(Vulkan REQUIRED)
add_definitions(-DDECAF_VULKAN)
endif()
if(DECAF_VALGRIND)
add_definitions(-DDECAF_VALGRIND)
endif()
if(DECAF_QT)
find_package(Qt5Widgets)
add_definitions(-DDECAF_QT)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FS")
add_definitions(-DNOMINMAX)
add_definitions(-DUNICODE -D_UNICODE)
# Disable warnings about using deprecated std::wstring_convert
add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
# Disable warnings generated by glbinding headers
add_definitions(-D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING)
else()
add_definitions(-DDECAF_USE_STDLAYOUT_BITFIELD)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -stdlib=libc++ -D_DARWIN_C_SOURCE")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
endif()
# Macro to map filters to folder structure for MSVC projects
macro(GroupSources curdir)
if(MSVC)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach(child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
GroupSources(${curdir}/${child})
else()
string(REPLACE "/" "\\" groupname ${curdir})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endif()
endmacro()
add_subdirectory("libraries")
add_subdirectory("src")
add_subdirectory("resources")
if(DECAF_BUILD_TOOLS)
add_subdirectory("tools")
endif()
if(DECAF_BUILD_TESTS OR DECAF_BUILD_WUT_TESTS)
enable_testing()
add_subdirectory("tests")
endif()