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.

FindThirdPartyOpenGL.cmake 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # ---------------------------------
  2. # Finds OpenGL toolkit
  3. #
  4. # Sets OpenGL_FOUND
  5. # Sets OpenGL_LIBRARIES
  6. # Sets OpenGL_LIBRARY_DIRS
  7. # Sets OpenGL_LDFLAGS
  8. # Sets OpenGL_LDFLAGS_OTHERS
  9. # Sets OpenGL_INCLUDE_DIRS
  10. # Sets OpenGL_CFLAGS
  11. # Sets OpenGL_CFLAGS_OTHERS
  12. # ---------------------------------
  13. IF(WIN32)
  14. FIND_LIBRARY(LIB_STANDARD_MODULE_GL opengl32)
  15. FIND_LIBRARY(LIB_STANDARD_MODULE_GLU glu32)
  16. IF(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  17. debug_message( " Found gl...")
  18. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_GL})
  19. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_GLU})
  20. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenGL)
  21. ELSE(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  22. MESSAGE(WARNING " FAILED to find gl...")
  23. ENDIF(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  24. ELSE(WIN32)
  25. INCLUDE("FindPkgConfig")
  26. pkg_check_modules(OpenGL glu)
  27. IF(OpenGL_FOUND)
  28. debug_message( " Found OpenGL...")
  29. INCLUDE_DIRECTORIES(${OpenGL_INCLUDE_DIRS})
  30. ADD_DEFINITIONS(${OpenGL_CFLAGS})
  31. ADD_DEFINITIONS(${OpenGL_CFLAGS_OTHERS})
  32. LINK_DIRECTORIES(${OpenGL_LIBRARY_DIRS})
  33. IF(NOT(APPLE))
  34. LINK_DIRECTORIES(${OpenGL_LIBRARY_DIRS}/mesa)
  35. ENDIF()
  36. FOREACH(OpenGL_LIB ${OpenGL_LIBRARIES} z)
  37. SET(OpenGL_LIB1 "OpenGL_LIB1-NOTFOUND")
  38. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB} PATHS ${OpenGL_LIBRARY_DIRS} ${OpenGL_LIBDIR} NO_DEFAULT_PATH)
  39. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB} PATHS ${OpenGL_LIBRARY_DIRS}/mesa ${OpenGL_LIBDIR}/mesa NO_DEFAULT_PATH)
  40. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB})
  41. IF(OpenGL_LIB1)
  42. debug_message( " [ OK ] Third party lib ${OpenGL_LIB1}")
  43. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenGL_LIB1})
  44. ELSE(OpenGL_LIB1)
  45. MESSAGE(WARNING " [FAILED] Third party lib ${OpenGL_LIB}")
  46. ENDIF(OpenGL_LIB1)
  47. ENDFOREACH(OpenGL_LIB)
  48. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenGL)
  49. ELSE(OpenGL_FOUND)
  50. MESSAGE(WARNING " FAILED to find OpenGL...")
  51. ENDIF(OpenGL_FOUND)
  52. ENDIF(WIN32)