FindAllegro51.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. find_package(PkgConfig)
  2. # Find main allegro and assume the rest is there too
  3. pkg_check_modules(Allegro51_PKGCONF allegro-5.1)
  4. # MESSAGE("lib: ${Allegro51_PKGCONF_LIBRARY_DIRS}")
  5. # MESSAGE("include: ${Allegro51_PKGCONF_INCLUDE_DIRS}")
  6. # Include dir
  7. find_path(Allegro51_INCLUDE_DIR
  8. NAMES allegro5/allegro5.h
  9. PATHS ${Allegro51_PKGCONF_INCLUDE_DIRS}
  10. )
  11. # message("include dir: ${Allegro51_INCLUDE_DIR}")
  12. # Names of all libraries in Allegro, without versions
  13. set(ALLEGRO51_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(ALLEGRO51_LIBRARIES "")
  20. # Find all libraries to link
  21. foreach(ALLEGRO51_ONE_LIBRARY ${ALLEGRO51_ALL_LIBRARIES})
  22. # message("${ALLEGRO51_ONE_LIBRARY}")
  23. find_library("${ALLEGRO51_ONE_LIBRARY}_AID" "${ALLEGRO51_ONE_LIBRARY}"
  24. ${Allegro51_PKGCONF_LIBRARY_DIRS}
  25. )
  26. set(Allegro51_LIBRARIES
  27. "${Allegro51_LIBRARIES}" "${${ALLEGRO51_ONE_LIBRARY}_AID}")
  28. # MESSAGE("${Allegro51_LIBRARIES}")
  29. endforeach(ALLEGRO51_ONE_LIBRARY)
  30. # Remove first empty erroneous "library"
  31. list(REMOVE_AT Allegro51_LIBRARIES 0)
  32. # MESSAGE("${Allegro51_LIBRARIES}")
  33. # message("${ALLEGRO51_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 "${Allegro51_INCLUDE_DIR}")
  39. set(ALLEGRO_LIBRARIES "${Allegro51_LIBRARIES}")
  40. # libfind_process(Allegro51)
  41. # MESSAGE("all libs: ${ALLEGRO_LIBRARIES}")
  42. # MESSAGE("all include: ${ALLEGRO_INCLUDE_DIR}")
  43. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Allegro51 DEFAULT_MSG ALLEGRO_LIBRARIES ALLEGRO_INCLUDE_DIR)
  44. MARK_AS_ADVANCED(ALLEGRO_INCLUDE_DIR ALLEGRO_LIBRARIES)
  45. # MESSAGE("${ALLEGRO_LIBRARIES}")