You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.1 KiB

  1. # - Try to find raylib
  2. # Options:
  3. # raylib_USE_STATIC_LIBS - OFF by default
  4. # raylib_VERBOSE - OFF by default
  5. # Once done, this defines a raylib target that can be passed to
  6. # target_link_libraries as well as following variables:
  7. #
  8. # raylib_FOUND - System has raylib installed
  9. # raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
  10. # raylib_LIBRARIES - The libraries needed to use raylib
  11. # raylib_LDFLAGS - The linker flags needed with raylib
  12. # raylib_DEFINITIONS - Compiler switches required for using raylib
  13. set(XPREFIX PC_RAYLIB)
  14. if (raylib_USE_STATIC_LIBS)
  15. set(XPREFIX ${XPREFIX}_STATIC)
  16. endif()
  17. find_package(PkgConfig)
  18. pkg_check_modules(${XPREFIX} REQUIRED raylib)
  19. set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
  20. find_path(raylib_INCLUDE_DIR
  21. NAMES raylib.h
  22. HINTS ${${XPREFIX}_INCLUDE_DIRS}
  23. )
  24. find_library(raylib_LIBRARY
  25. NAMES raylib
  26. HINTS ${${XPREFIX}_LIBRARY_DIRS}
  27. )
  28. set(raylib_LIBRARIES ${raylib_LIBRARY})
  29. set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
  30. set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
  31. set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
  32. set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
  33. include(FindPackageHandleStandardArgs)
  34. find_package_handle_standard_args(raylib DEFAULT_MSG
  35. raylib_LIBRARY
  36. raylib_INCLUDE_DIR
  37. )
  38. mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
  39. if (raylib_USE_STATIC_LIBS)
  40. add_library(raylib STATIC IMPORTED GLOBAL)
  41. else()
  42. add_library(raylib SHARED IMPORTED GLOBAL)
  43. endif()
  44. string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
  45. set_target_properties(raylib
  46. PROPERTIES
  47. IMPORTED_LOCATION "${raylib_LIBRARIES}"
  48. INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
  49. INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
  50. INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
  51. )
  52. if (raylib_VERBOSE)
  53. message(STATUS "raylib_FOUND: ${raylib_FOUND}")
  54. message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
  55. message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
  56. message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
  57. message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
  58. endif()