opengl.cmake 774 B

123456789101112131415161718192021222324
  1. # 1. Define module
  2. igl_add_library(igl_opengl)
  3. # 2. Include headers
  4. include(GNUInstallDirs)
  5. target_include_directories(igl_opengl ${IGL_SCOPE}
  6. $<BUILD_INTERFACE:${libigl_SOURCE_DIR}/include>
  7. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  8. )
  9. # 3. Target sources
  10. file(GLOB INC_FILES "${libigl_SOURCE_DIR}/include/igl/opengl/*.h")
  11. file(GLOB SRC_FILES "${libigl_SOURCE_DIR}/include/igl/opengl/*.cpp")
  12. igl_target_sources(igl_opengl ${INC_FILES} ${SRC_FILES})
  13. # 4. Dependencies
  14. include(glad)
  15. find_package(OpenGL REQUIRED OPTIONAL_COMPONENTS OpenGL)
  16. target_link_libraries(igl_opengl ${IGL_SCOPE}
  17. igl::core
  18. glad::glad
  19. # Link against OpenGL::OpenGL if available, or fallback to OpenGL::GL
  20. $<IF:$<TARGET_EXISTS:OpenGL::OpenGL>,OpenGL::OpenGL,OpenGL::GL>
  21. )