FindGL2PS.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. find_path(GL2PS_INCLUDE_DIR
  2. NAMES gl2ps.h
  3. DOC "gl2ps include directories")
  4. mark_as_advanced(GL2PS_INCLUDE_DIR)
  5. find_library(GL2PS_LIBRARY
  6. NAMES gl2ps
  7. DOC "gl2ps library")
  8. mark_as_advanced(GL2PS_LIBRARY)
  9. if (GL2PS_INCLUDE_DIR)
  10. file(STRINGS "${GL2PS_INCLUDE_DIR}/gl2ps.h" _gl2ps_version_lines REGEX "#define[ \t]+GL2PS_(MAJOR|MINOR|PATCH)_VERSION[ \t]+")
  11. string(REGEX REPLACE ".*GL2PS_MAJOR_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_major "${_gl2ps_version_lines}")
  12. string(REGEX REPLACE ".*GL2PS_MINOR_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_minor "${_gl2ps_version_lines}")
  13. string(REGEX REPLACE ".*GL2PS_PATCH_VERSION *\([0-9]*\).*" "\\1" _gl2ps_version_patch "${_gl2ps_version_lines}")
  14. set(GL2PS_VERSION "${_gl2ps_version_major}.${_gl2ps_version_minor}.${_gl2ps_version_patch}")
  15. unset(_gl2ps_version_major)
  16. unset(_gl2ps_version_minor)
  17. unset(_gl2ps_version_patch)
  18. unset(_gl2ps_version_lines)
  19. endif ()
  20. include(FindPackageHandleStandardArgs)
  21. find_package_handle_standard_args(GL2PS
  22. REQUIRED_VARS GL2PS_LIBRARY GL2PS_INCLUDE_DIR
  23. VERSION_VAR GL2PS_VERSION)
  24. if (GL2PS_FOUND)
  25. set(GL2PS_INCLUDE_DIRS "${GL2PS_INCLUDE_DIR}")
  26. set(GL2PS_LIBRARIES "${GL2PS_LIBRARY}")
  27. if (NOT TARGET GL2PS::GL2PS)
  28. add_library(GL2PS::GL2PS UNKNOWN IMPORTED)
  29. set_target_properties(GL2PS::GL2PS PROPERTIES
  30. IMPORTED_LOCATION "${GL2PS_LIBRARY}"
  31. INTERFACE_INCLUDE_DIRECTORIES "${GL2PS_INCLUDE_DIR}")
  32. endif ()
  33. endif ()