FindAllegro5.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. find_package(PkgConfig)
  2. # Find main allegro and assume the rest is there too
  3. pkg_check_modules(Allegro5_PKGCONF allegro-5)
  4. # Perhaps use this later?
  5. # pkg_search_module(ALLEGRO5 REQUIRED allegro-5 allegro-5.0)
  6. # MESSAGE("lib: ${Allegro5_PKGCONF_LIBRARY_DIRS}")
  7. # MESSAGE("include: ${Allegro5_PKGCONF_INCLUDE_DIRS}")
  8. # Include dir
  9. find_path(Allegro5_INCLUDE_DIR
  10. NAMES allegro5/allegro5.h
  11. PATHS ${Allegro5_PKGCONF_INCLUDE_DIRS}
  12. )
  13. # message("include dir: ${Allegro5_INCLUDE_DIR}")
  14. # Names of all libraries in Allegro, without versions
  15. set(ALLEGRO5_ALL_LIBRARIES
  16. allegro allegro_image allegro_font
  17. allegro_primitives allegro_ttf allegro_audio
  18. allegro_dialog allegro_memfile allegro_acodec
  19. allegro_color allegro_main allegro_physfs
  20. )
  21. # set(ALLEGRO5_LIBRARIES "")
  22. # Find all libraries to link
  23. foreach(ALLEGRO5_ONE_LIBRARY ${ALLEGRO5_ALL_LIBRARIES})
  24. # message("${ALLEGRO5_ONE_LIBRARY}")
  25. find_library("${ALLEGRO5_ONE_LIBRARY}_AID" "${ALLEGRO5_ONE_LIBRARY}"
  26. ${Allegro5_PKGCONF_LIBRARY_DIRS}
  27. )
  28. set(Allegro5_LIBRARIES
  29. "${Allegro5_LIBRARIES}" "${${ALLEGRO5_ONE_LIBRARY}_AID}")
  30. # MESSAGE("${Allegro5_LIBRARIES}")
  31. endforeach(ALLEGRO5_ONE_LIBRARY)
  32. # Remove first empty erroneous "library"
  33. list(REMOVE_AT Allegro5_LIBRARIES 0)
  34. # MESSAGE("${Allegro5_LIBRARIES}")
  35. # message("${ALLEGRO5_LIBRARIES}")
  36. # allegro_image allegro_font allegro_primitives
  37. # allegro_ttf allegro_audio allegro_dialog allegro_acodec
  38. # allegro_color allegro_main allegro_physfs
  39. # Set the include dir variables and the libraries and let libfind_process do the rest.
  40. set(ALLEGRO_INCLUDE_DIR "${Allegro5_INCLUDE_DIR}")
  41. set(ALLEGRO_LIBRARIES "${Allegro5_LIBRARIES}")
  42. # libfind_process(Allegro5)
  43. # MESSAGE("all libs: ${ALLEGRO_LIBRARIES}")
  44. # MESSAGE("all include: ${ALLEGRO_INCLUDE_DIR}")
  45. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Allegro5 DEFAULT_MSG ALLEGRO_LIBRARIES ALLEGRO_INCLUDE_DIR)
  46. MARK_AS_ADVANCED(ALLEGRO_INCLUDE_DIR ALLEGRO_LIBRARIES)
  47. # MESSAGE("${ALLEGRO_LIBRARIES}")