Debian Codegraph @

Source/CMakeLists.txt

raw
1 option(DOLPHIN_CXX_FLAGS "Flags used to compile Dolphin-only sources" "")
2 if(DOLPHIN_CXX_FLAGS)
3 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DOLPHIN_CXX_FLAGS}")
4 endif()
5
6 if(CMAKE_SYSTEM_NAME MATCHES "Windows")
7 add_definitions(-DNOMINMAX)
8 add_definitions(-DUNICODE)
9 add_definitions(-D_UNICODE)
10 add_definitions(-DWIN32_LEAN_AND_MEAN)
11 add_definitions(-D_SCL_SECURE_NO_WARNINGS)
12 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
13 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
14 add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
15 add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
16 endif()
17
18 if (NOT MSVC)
19 set(CMAKE_CXX_STANDARD 23)
20 set(CMAKE_CXX_STANDARD_REQUIRED ON)
21 set(CMAKE_CXX_EXTENSIONS OFF)
22 endif()
23
24 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
25
26 if (MSVC)
27 # Compile PCH
28 add_subdirectory(PCH)
29 else()
30 check_and_add_flag(HAVE_WALL -Wall)
31 # TODO: would like these but they produce overwhelming amounts of warnings
32 #check_and_add_flag(EXTRA -Wextra)
33 #check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers)
34 #check_and_add_flag(SWITCH_DEFAULT -Wswitch-default)
35 #check_and_add_flag(FLOAT_EQUAL -Wfloat-equal)
36 #check_and_add_flag(CONVERSION -Wconversion)
37 #check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant)
38 check_and_add_flag(TYPE_LIMITS -Wtype-limits)
39 check_and_add_flag(SIGN_COMPARE -Wsign-compare)
40 check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers)
41 check_and_add_flag(UNINITIALIZED -Wuninitialized)
42 check_and_add_flag(LOGICAL_OP -Wlogical-op)
43 check_and_add_flag(SHADOW -Wshadow)
44 check_and_add_flag(SHADOW_FIELD_IN_CONSTRUCTOR -Wshadow-field-in-constructor)
45 check_and_add_flag(INIT_SELF -Winit-self)
46 check_and_add_flag(MISSING_DECLARATIONS -Wmissing-declarations)
47 check_and_add_flag(MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations)
48
49 # Disable -Wstringop-truncation warnings as they result in many false positives.
50 # In most (all?) cases where std::strncpy is used, we want to fill the entire buffer
51 # or match emulated code that also ignores the null terminator, so the warnings are not useful.
52 # Given that Dolphin itself mostly uses std::string, they do not really help catch any bugs.
53 check_cxx_compiler_flag(-Wstringop-truncation HAS_STRINGOP_TRUNCATION_WARNING)
54 if (HAS_STRINGOP_TRUNCATION_WARNING)
55 check_and_add_flag(NO_STRINGOP_TRUNCATION -Wno-stringop-truncation)
56 endif()
57
58 # Format string issues that the compiler can detect should be compile time errors.
59 check_cxx_compiler_flag(-Wformat HAS_FORMAT_WARNING)
60 if (HAS_FORMAT_WARNING)
61 check_and_add_flag(FORMAT_WARNING_TO_ERROR -Werror=format)
62 endif()
63
64 # Trigraphs support is generally disabled by default, but some compilers (GCC) may still warn when
65 # one hypothetical trigraph is encountered. The warning is generally not interesting.
66 check_cxx_compiler_flag(-Wtrigraphs HAS_TRIGRAPHS_WARNING)
67 if (HAS_TRIGRAPHS_WARNING)
68 check_and_add_flag(NO_TRIGRAPHS_WARNING -Wno-trigraphs)
69 endif()
70 endif()
71
72 # These aren't actually needed for C11/C++11
73 # but some dependencies require them (LLVM, libav).
74 add_definitions(-D__STDC_LIMIT_MACROS)
75 add_definitions(-D__STDC_CONSTANT_MACROS)
76
77 check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
78 if(HAVE_ELF_AUX_INFO)
79 add_definitions(-DHAVE_ELF_AUX_INFO)
80 endif()
81
82 add_subdirectory(Core)
83 if (ANDROID)
84 add_subdirectory(Android/jni)
85 endif()
86
87 if (ENABLE_TESTS)
88 add_subdirectory(UnitTests)
89 endif()
90
91 if (DSPTOOL)
92 add_subdirectory(DSPTool)
93 endif()
94
95 # TODO: Add DSPSpy. Preferably make it option() and cpack component