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

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyOpenGL)
  14. IF(WIN32)
  15. FIND_LIBRARY(LIB_STANDARD_MODULE_GL opengl32)
  16. FIND_LIBRARY(LIB_STANDARD_MODULE_GLU glu32)
  17. IF(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  18. OV_PRINT(OV_PRINTED " Found gl...")
  19. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_GL})
  20. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_GLU})
  21. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenGL)
  22. ELSE(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  23. MESSAGE(WARNING " FAILED to find gl...")
  24. ENDIF(LIB_STANDARD_MODULE_GL AND LIB_STANDARD_MODULE_GLU)
  25. ELSE(WIN32)
  26. INCLUDE("FindPkgConfig")
  27. pkg_check_modules(OpenGL glu)
  28. IF(OpenGL_FOUND)
  29. OV_PRINT(OV_PRINTED " Found OpenGL...")
  30. INCLUDE_DIRECTORIES(${OpenGL_INCLUDE_DIRS})
  31. ADD_DEFINITIONS(${OpenGL_CFLAGS})
  32. ADD_DEFINITIONS(${OpenGL_CFLAGS_OTHERS})
  33. LINK_DIRECTORIES(${OpenGL_LIBRARY_DIRS})
  34. IF(NOT(APPLE))
  35. LINK_DIRECTORIES(${OpenGL_LIBRARY_DIRS}/mesa)
  36. ENDIF()
  37. FOREACH(OpenGL_LIB ${OpenGL_LIBRARIES} z)
  38. SET(OpenGL_LIB1 "OpenGL_LIB1-NOTFOUND")
  39. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB} PATHS ${OpenGL_LIBRARY_DIRS} ${OpenGL_LIBDIR} NO_DEFAULT_PATH)
  40. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB} PATHS ${OpenGL_LIBRARY_DIRS}/mesa ${OpenGL_LIBDIR}/mesa NO_DEFAULT_PATH)
  41. FIND_LIBRARY(OpenGL_LIB1 NAMES ${OpenGL_LIB})
  42. IF(OpenGL_LIB1)
  43. OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${OpenGL_LIB1}")
  44. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenGL_LIB1})
  45. ELSE(OpenGL_LIB1)
  46. MESSAGE(WARNING " [FAILED] Third party lib ${OpenGL_LIB}")
  47. ENDIF(OpenGL_LIB1)
  48. ENDFOREACH(OpenGL_LIB)
  49. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenGL)
  50. ELSE(OpenGL_FOUND)
  51. MESSAGE(WARNING " FAILED to find OpenGL...")
  52. ENDIF(OpenGL_FOUND)
  53. ENDIF(WIN32)