xmake.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. -- project
  2. set_project("CommonLibSSE")
  3. -- set architecture
  4. set_arch("x64")
  5. -- set languages
  6. set_languages("c++20")
  7. -- add rules
  8. add_rules("mode.debug", "mode.release")
  9. -- set warnings
  10. set_warnings("allextra", "error")
  11. -- set optimization
  12. set_optimize("faster")
  13. -- set policies
  14. set_policy("build.optimization.lto", true)
  15. -- add options
  16. option("skyrim_se")
  17. set_default(true)
  18. set_description("Enable runtime support for Skyrim SE")
  19. add_defines("ENABLE_SKYRIM_SE=1")
  20. option_end()
  21. option("skyrim_ae")
  22. set_default(true)
  23. set_description("Enable runtime support for Skyrim AE")
  24. add_defines("ENABLE_SKYRIM_AE=1")
  25. option_end()
  26. option("skyrim_vr")
  27. set_default(true)
  28. set_description("Enable runtime support for Skyrim VR")
  29. add_defines("ENABLE_SKYRIM_VR=1")
  30. option_end()
  31. option("skse_xbyak")
  32. set_default(false)
  33. set_description("Enable trampoline support for Xbyak")
  34. add_defines("SKSE_SUPPORT_XBYAK=1")
  35. option_end()
  36. -- add packages
  37. add_requires("fmt", "spdlog", "rapidcsv")
  38. if has_config("skse_xbyak") then
  39. add_requires("xbyak")
  40. end
  41. -- targets
  42. target("CommonLibSSE")
  43. set_kind("static")
  44. -- add packages
  45. add_packages("fmt", "spdlog", "rapidcsv")
  46. if has_config("skse_xbyak") then
  47. add_packages("xbyak")
  48. end
  49. -- add options
  50. add_options("skyrim_se", "skyrim_ae", "skyrim_vr", "skse_xbyak")
  51. -- add system links
  52. add_syslinks("version", "user32", "shell32", "ole32", "advapi32")
  53. -- add source files
  54. add_files("src/**.cpp")
  55. -- add header files
  56. add_includedirs("include", { public = true })
  57. add_headerfiles(
  58. "include/(RE/**.h)",
  59. "include/(REL/**.h)",
  60. "include/(SKSE/**.h)"
  61. )
  62. -- set precompiled header
  63. set_pcxxheader("include/SKSE/Impl/PCH.h")
  64. -- add defines
  65. add_defines("WIN32_LEAN_AND_MEAN", "NOMINMAX", "UNICODE", "_UNICODE")
  66. -- add flags
  67. add_cxxflags("/permissive-")
  68. on_config(function(target)
  69. if target:has_tool("cxx", "cl") then
  70. target:add("cxxflags", "/Zc:preprocessor", "/external:W0", "/bigobj")
  71. -- warnings -> errors
  72. target:add("cxxflags", "/we4715") -- `function` : not all control paths return a value
  73. -- disable warnings
  74. target:add("cxxflags", "/wd4005") -- macro redefinition
  75. target:add("cxxflags", "/wd4061") -- enumerator `identifier` in switch of enum `enumeration` is not explicitly handled by a case label
  76. target:add("cxxflags", "/wd4200") -- nonstandard extension used : zero-sized array in struct/union
  77. target:add("cxxflags", "/wd4201") -- nonstandard extension used : nameless struct/union
  78. target:add("cxxflags", "/wd4265") -- 'type': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
  79. target:add("cxxflags", "/wd4266") -- 'function' : no override available for virtual member function from base 'type'; function is hidden
  80. target:add("cxxflags", "/wd4371") -- 'classname': layout of class may have changed from a previous version of the compiler due to better packing of member 'member'
  81. target:add("cxxflags", "/wd4514") -- 'function' : unreferenced inline function has been removed
  82. target:add("cxxflags", "/wd4582") -- 'type': constructor is not implicitly called
  83. target:add("cxxflags", "/wd4583") -- 'type': destructor is not implicitly called
  84. target:add("cxxflags", "/wd4623") -- 'derived class' : default constructor was implicitly defined as deleted because a base class default constructor is inaccessible or deleted
  85. target:add("cxxflags", "/wd4625") -- 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
  86. target:add("cxxflags", "/wd4626") -- 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
  87. target:add("cxxflags", "/wd4710") -- 'function' : function not inlined
  88. target:add("cxxflags", "/wd4711") -- function 'function' selected for inline expansion
  89. target:add("cxxflags", "/wd4820") -- 'bytes' bytes padding added after construct 'member_name'
  90. target:add("cxxflags", "/wd5026") -- 'type': move constructor was implicitly defined as deleted
  91. target:add("cxxflags", "/wd5027") -- 'type': move assignment operator was implicitly defined as deleted
  92. target:add("cxxflags", "/wd5045") -- compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
  93. target:add("cxxflags", "/wd5053") -- support for 'explicit(<expr>)' in C++17 and earlier is a vendor extension
  94. target:add("cxxflags", "/wd5204") -- 'type-name': class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
  95. target:add("cxxflags", "/wd5220") -- 'member': a non-static data member with a volatile qualified type no longer implies that compiler generated copy / move constructors and copy / move assignment operators are not trivial
  96. else
  97. -- disable warnings
  98. target:add("cxxflags", "-Wno-overloaded-virtual")
  99. target:add("cxxflags", "-Wno-delete-non-abstract-non-virtual-dtor")
  100. target:add("cxxflags", "-Wno-reinterpret-base-class")
  101. end
  102. end)