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.

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