FindAllegro50.cmake 1.9 KB

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