find_package(Eigen3 REQUIRED)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})

find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
include_directories(SYSTEM ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS})
if(WIN32 AND NOT BUILD_SHARED_LIBS)
  add_definitions(-DGLEW_STATIC)
endif()

set(HEADERS
  avogadrogl.h
  avogadrorendering.h
  bufferobject.h
  camera.h
  cylindergeometry.h
  drawable.h
  geometrynode.h
  geometryvisitor.h
  groupnode.h
  glrenderer.h
  glrendervisitor.h
  linestripgeometry.h
  meshgeometry.h
  node.h
  povrayvisitor.h
  primitive.h
  scene.h
  shader.h
  shaderprogram.h
  spheregeometry.h
  textlabel2d.h
  textlabel3d.h
  textlabelbase.h
  textproperties.h
  textrenderstrategy.h
  texture2d.h
  transformnode.h
  visitor.h
  volumegeometry.h
  vrmlvisitor.h
)

set(SOURCES
  bufferobject.cpp
  camera.cpp
  cylindergeometry.cpp
  drawable.cpp
  geometrynode.cpp
  geometryvisitor.cpp
  groupnode.cpp
  glrenderer.cpp
  glrendervisitor.cpp
  linestripgeometry.cpp
  meshgeometry.cpp
  node.cpp
  povrayvisitor.cpp
  scene.cpp
  shader.cpp
  shaderprogram.cpp
  spheregeometry.cpp
  textlabel2d.cpp
  textlabel3d.cpp
  textlabelbase.cpp
  textproperties.cpp
  textrenderstrategy.cpp
  texture2d.cpp
  transformnode.cpp
  visitor.cpp
  volumegeometry.cpp
  vrmlvisitor.cpp
  ambientocclusionspheregeometry.cpp
)

set(shader_files
  "cylinders_fs.glsl"
  "cylinders_vs.glsl"
  "linestrip_fs.glsl"
  "linestrip_vs.glsl"
  "mesh_fs.glsl"
  "mesh_vs.glsl"
  "spheres_fs.glsl"
  "spheres_vs.glsl"
  "sphere_ao_depth_vs.glsl"
  "sphere_ao_depth_fs.glsl"
  "sphere_ao_bake_vs.glsl"
  "sphere_ao_bake_fs.glsl"
  "sphere_ao_render_vs.glsl"
  "sphere_ao_render_fs.glsl"
  "textlabelbase_fs.glsl"
  "textlabelbase_vs.glsl"
)
foreach(file ${shader_files})
  get_filename_component(file_we ${file} NAME_WE)
  set(src  ${CMAKE_CURRENT_SOURCE_DIR}/${file})
  set(resh ${CMAKE_CURRENT_BINARY_DIR}/${file_we}.h)
  list(APPEND shader_h_files ${resh})
  add_custom_command(
    OUTPUT ${resh}
    DEPENDS ${src} encodefile
    COMMAND encodefile
    ARGS ${src} ${resh} ${file_we}
    COMMENT "Encoding ${src}"
    )
endforeach()

avogadro_add_library(AvogadroRendering ${HEADERS} ${SOURCES} ${shader_h_files})
target_link_libraries(AvogadroRendering
  ${GLEW_LIBRARY}
  ${OPENGL_LIBRARIES})
