project(VTKGL2PS)

# Dependency mask
include_regular_expression(".*")

# Depend on OpenGL
find_package(OpenGL REQUIRED)

# Include paths
include_directories(
  ${VTKGL2PS_SOURCE_DIR}/
  ${OPENGL_INCLUDE_DIR}
)

# Source files
set(GL2PS_srcs
  gl2ps.c
)

# Define the library (and install it)
vtk_add_library(vtkgl2ps ${GL2PS_srcs})

# Setup definitions
if(WIN32)
  set_source_files_properties(${GL2PS_srcs}
    PROPERTIES
      COMPILE_DEFINITIONS "GL2PSDLL;GL2PSDLL_EXPORTS")
endif()

# Linking
target_link_libraries(vtkgl2ps ${OPENGL_LIBRARIES})
if(UNIX)
  target_link_libraries(vtkgl2ps m)
endif()

# Install headers
if(NOT VTK_INSTALL_NO_DEVELOPMENT)
  install(FILES
    ${VTKGL2PS_SOURCE_DIR}/gl2ps.h
    DESTINATION ${VTK_INSTALL_INCLUDE_DIR}/vtkgl2ps/include
    COMPONENT Development)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)

project(VTKGL2PS)

# Dependency mask
include_regular_expression(".*")

# Depend on OpenGL
if(NOT VTK_OPENGL_HAS_OSMESA)
  find_package(OpenGL REQUIRED)
  set(GL2PS_GL_LIBRARIES ${OPENGL_LIBRARIES})
  set(GL2PS_GL_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
else()
  set(GL2PS_GL_LIBRARIES ${OSMESA_LIBRARY})
  set(GL2PS_GL_INCLUDE_DIR ${OSMESA_INCLUDE_DIR})
endif()

# Need math on UNIX
if(UNIX)
  set(GL2PS_GL_LIBRARIES ${GL2PS_GL_LIBRARIES} m)
endif()

# Include paths
include_directories(
  ${VTKGL2PS_SOURCE_DIR}/
  ${GL2PS_GL_INCLUDE_DIR}
)

# Source files
set(GL2PS_srcs
  gl2ps.c
)

# Define the library (and install it)
vtk_add_library(vtkgl2ps ${GL2PS_srcs})

# Setup definitions
if(WIN32)
  set_source_files_properties(${GL2PS_srcs}
    PROPERTIES
      COMPILE_DEFINITIONS "GL2PSDLL;GL2PSDLL_EXPORTS")
endif()

# Linking
target_link_libraries(vtkgl2ps ${GL2PS_GL_LIBRARIES})

# Install headers
if(NOT VTK_INSTALL_NO_DEVELOPMENT)
  install(FILES
    ${VTKGL2PS_SOURCE_DIR}/gl2ps.h
    DESTINATION ${VTK_INSTALL_INCLUDE_DIR}/vtkgl2ps/include
    COMPONENT Development)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)

Fix GL2PS building with OSMesa.
Fix GL2PS building with OSMesa.

The GL2PS module needed to be modified to use the OSMesa library
and headers when needed.

Change-Id: I3ee5d7c60aab1ff2e875cc0607dccbd406095a61
