CMakeLists.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Enable modules to include each other's files
  2. include_directories(.)
  3. # CMake seems to only define _DEBUG on Windows
  4. set_property(DIRECTORY APPEND PROPERTY
  5. COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
  6. # Set compilation flags
  7. if (MSVC)
  8. set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
  9. # Silence "deprecation" warnings
  10. add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
  11. # Avoid windows.h junk
  12. add_definitions(-DNOMINMAX)
  13. # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors.
  14. add_definitions(-DWIN32_LEAN_AND_MEAN)
  15. # Ensure that projects build with Unicode support.
  16. add_definitions(-DUNICODE -D_UNICODE)
  17. # /W3 - Level 3 warnings
  18. # /MP - Multi-threaded compilation
  19. # /Zi - Output debugging information
  20. # /Zo - Enhanced debug info for optimized builds
  21. # /permissive- - Enables stricter C++ standards conformance checks
  22. # /EHsc - C++-only exception handling semantics
  23. # /volatile:iso - Use strict standards-compliant volatile semantics.
  24. # /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates
  25. # /Zc:inline - Let codegen omit inline functions in object files
  26. # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null
  27. add_compile_options(
  28. /MP
  29. /Zi
  30. /Zo
  31. /permissive-
  32. /EHsc
  33. /std:c++latest
  34. /volatile:iso
  35. /Zc:externConstexpr
  36. /Zc:inline
  37. /Zc:throwingNew
  38. # Warnings
  39. /W3
  40. /we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect
  41. /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
  42. /we4555 # Expression has no effect; expected expression with side-effect
  43. /we4834 # Discarding return value of function with 'nodiscard' attribute
  44. )
  45. # /GS- - No stack buffer overflow checks
  46. add_compile_options("$<$<CONFIG:Release>:/GS->")
  47. set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE)
  48. set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
  49. else()
  50. add_compile_options(
  51. -Wall
  52. -Werror=implicit-fallthrough
  53. -Werror=missing-declarations
  54. -Werror=reorder
  55. -Werror=uninitialized
  56. -Werror=unused-result
  57. -Wextra
  58. -Wmissing-declarations
  59. -Wno-attributes
  60. -Wno-invalid-offsetof
  61. -Wno-unused-parameter
  62. )
  63. # TODO: Remove when we update to a GCC compiler that enables this
  64. # by default (i.e. GCC 10 or newer).
  65. if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
  66. add_compile_options(-fconcepts)
  67. endif()
  68. if (ARCHITECTURE_x86_64)
  69. add_compile_options("-mcx16")
  70. endif()
  71. if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
  72. add_compile_options("-stdlib=libc++")
  73. endif()
  74. # Set file offset size to 64 bits.
  75. #
  76. # On modern Unixes, this is typically already the case. The lone exception is
  77. # glibc, which may default to 32 bits. glibc allows this to be configured
  78. # by setting _FILE_OFFSET_BITS.
  79. if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
  80. add_definitions(-D_FILE_OFFSET_BITS=64)
  81. endif()
  82. if (MINGW)
  83. add_definitions(-DMINGW_HAS_SECURE_API)
  84. if (MINGW_STATIC_BUILD)
  85. add_definitions(-DQT_STATICPLUGIN)
  86. add_compile_options("-static")
  87. endif()
  88. endif()
  89. if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
  90. # GNU ar: Create thin archive files.
  91. # Requires binutils-2.19 or later.
  92. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
  93. set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
  94. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
  95. set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
  96. endif()
  97. endif()
  98. add_subdirectory(common)
  99. add_subdirectory(core)
  100. add_subdirectory(audio_core)
  101. add_subdirectory(video_core)
  102. add_subdirectory(input_common)
  103. add_subdirectory(tests)
  104. if (ENABLE_SDL2)
  105. add_subdirectory(yuzu_cmd)
  106. add_subdirectory(yuzu_tester)
  107. endif()
  108. if (ENABLE_QT)
  109. add_subdirectory(yuzu)
  110. endif()
  111. if (ENABLE_WEB_SERVICE)
  112. add_subdirectory(web_service)
  113. endif()