xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("ois")
  2. set_homepage("https://wgois.github.io/OIS/")
  3. set_description("Official OIS repository. Object oriented Input System")
  4. set_license("zlib")
  5. add_urls("https://github.com/wgois/OIS/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/wgois/OIS.git")
  7. add_versions("v1.5.1", "614f6ef6d69cf6d84f1b50efff46a6c1acce426933e5f0dcf29862ea8332af73")
  8. add_deps("cmake")
  9. if is_plat("linux", "bsd") then
  10. add_deps("libx11")
  11. elseif is_plat("macosx") then
  12. add_frameworks("Cocoa", "Foundation", "Carbon", "IOKit")
  13. elseif is_plat("windows", "mingw") then
  14. add_syslinks("dinput8", "dxguid", "ole32", "oleaut32", "user32", "uuid", "xinput", "winmm")
  15. end
  16. on_install("windows", "linux", "macosx", function (package)
  17. local configs = {
  18. "-DOIS_BUILD_DEMOS=OFF",
  19. "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
  20. }
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DOIS_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:check_cxxsnippets({test = [[
  27. #include <ois/OIS.h>
  28. class InputListener : public OIS::KeyListener {
  29. public:
  30. bool keyPressed(const OIS::KeyEvent& arg) override { return true; }
  31. bool keyReleased(const OIS::KeyEvent& arg) override { return true; }
  32. };
  33. void test() {
  34. OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(0);
  35. OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
  36. InputListener inputListener;
  37. keyboard->setEventCallback(&inputListener);
  38. keyboard->capture();
  39. inputManager->destroyInputObject(keyboard);
  40. OIS::InputManager::destroyInputSystem(inputManager);
  41. }
  42. ]]}, {configs = {languages = "cxx11"}}))
  43. end)