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.

76 lines
2.2 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. find_package(PkgConfig QUIET)
  15. pkg_check_modules(${XPREFIX} QUIET raylib)
  16. if (raylib_USE_STATIC_LIBS)
  17. set(XPREFIX ${XPREFIX}_STATIC)
  18. endif()
  19. set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
  20. find_path(raylib_INCLUDE_DIR
  21. NAMES raylib.h
  22. HINTS ${${XPREFIX}_INCLUDE_DIRS}
  23. )
  24. set(RAYLIB_NAMES raylib)
  25. if (raylib_USE_STATIC_LIBS)
  26. set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
  27. endif()
  28. find_library(raylib_LIBRARY
  29. NAMES ${RAYLIB_NAMES}
  30. HINTS ${${XPREFIX}_LIBRARY_DIRS}
  31. )
  32. set(raylib_LIBRARIES ${raylib_LIBRARY})
  33. set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
  34. set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
  35. set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
  36. set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
  37. include(FindPackageHandleStandardArgs)
  38. find_package_handle_standard_args(raylib DEFAULT_MSG
  39. raylib_LIBRARY
  40. raylib_INCLUDE_DIR
  41. )
  42. mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
  43. if (raylib_USE_STATIC_LIBS)
  44. add_library(raylib STATIC IMPORTED GLOBAL)
  45. else()
  46. add_library(raylib SHARED IMPORTED GLOBAL)
  47. endif()
  48. string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
  49. set_target_properties(raylib
  50. PROPERTIES
  51. IMPORTED_LOCATION "${raylib_LIBRARIES}"
  52. INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
  53. INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
  54. INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
  55. )
  56. if (raylib_VERBOSE)
  57. message(STATUS "raylib_FOUND: ${raylib_FOUND}")
  58. message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
  59. message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
  60. message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
  61. message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
  62. endif()