project( OGLFT )

CMAKE_MINIMUM_REQUIRED (VERSION 2.6)

Set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )

FIND_PACKAGE( OpenGL REQUIRED )
FIND_PACKAGE( FreeType2 REQUIRED )

INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/liboglft)

IF( ENABLE_QT )
  FIND_PACKAGE( QT REQUIRED )
  IF( DESIRED_QT_VERSION EQUAL 3 )
    FIND_PACKAGE( KDE3 REQUIRED )
  ENDIF( DESIRED_QT_VERSION EQUAL 3 )
ENDIF( ENABLE_QT )

If( ENABLE_GLE )
  find_package( GLE )
endif( ENABLE_GLE )

#
# Test to determine if we want the "tripledot" (variable) form of the GLU tesselator callback.
#
if(NOT GLU_TESS_CALLBACK_TRIPLEDOT)
    if(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
        # Skip the compile check for platforms that never need the variable form
        set(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT false)
    else(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
        # For other platforms perform the check
        include(CheckCXXSourceCompiles)
        include(CheckIncludeFiles)
        set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR})
        set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARY})
        check_include_files(OpenGL/gl.h HAVE_OPENGL_DIR)
        if(HAVE_OPENGL_DIR)
                set(OPENGL_DIR_PREFIX "OpenGL")
        else(HAVE_OPENGL_DIR)
                set(OPENGL_DIR_PREFIX "GL")
        endif(HAVE_OPENGL_DIR)
        set(GLUTESS_TEST_SOURCE "
                #include <${OPENGL_DIR_PREFIX}/gl.h>
                #include <${OPENGL_DIR_PREFIX}/glu.h>
                typedef GLvoid (*GLUTessCallback)(...);
                static void testcb(GLvoid *, void*) { }
                int main() {
                  GLUtesselator *t = gluNewTess();
                  gluTessCallback(t, GLU_TESS_VERTEX_DATA, GLUTessCallback(testcb));
                  return 0;
                }
                ")
        check_cxx_source_compiles("${GLUTESS_TEST_SOURCE}" GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No)
        set(GLU_TESS_CALLBACK_TRIPLEDOT ${GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No})
    endif(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
endif(NOT GLU_TESS_CALLBACK_TRIPLEDOT)

add_subdirectory( liboglft )

set( BUILD_OGLFT_TESTS OFF CACHE BOOL "Build oglft tests." )

if( BUILD_OGLFT_TESTS )
  enable_testing()
  add_subdirectory( tests )
endif( BUILD_OGLFT_TESTS )
