#******************************************************************************
#
#       Copyright:      2006-2022 Paul Obermeier (obermeier@tcl3d.org)
#
#                       See the file "Tcl3D_License.txt" for information on
#                       usage and redistribution of this file, and for a
#                       DISCLAIMER OF ALL WARRANTIES.
#
#       Module:         Tcl3D -> tcl3dGl2ps
#       Filename:       CMakeLists.txt
#
#       Author:         Paul Obermeier
#
#       Description:    Makefile for the tcl3dGl2ps subpackage.
#
#******************************************************************************

IF( TCL3D_BUILD_GL2PS )

    SET( TARGET      tcl3dGl2ps )
    SET( TARGET_BASE tcl3dGl2psBase )

    SET( TARGET_DEF "-DUSE_GL2PS_IF" )

    ADD_DEFINITIONS( ${TARGET_DEF} )

    # Build base files of this module.
    FIND_SOURCES( BASE_SOURCES . )
    ADD_LIBRARY( ${TARGET_BASE} STATIC ${BASE_SOURCES} )
    SET_TARGET_PROPERTIES( ${TARGET_BASE} PROPERTIES PREFIX "" )

    # Build wrapper with SWIG.
    SET( INTERFACE_FILE swigfiles/${TARGET}.i)

    INCLUDE( ${SWIG_USE_FILE} )
  
    SET( CMAKE_SWIG_FLAGS
        ${TARGET_DEF}
        ${COMMON_SWIG_FLAGS}
        -I${CMAKE_CURRENT_SOURCE_DIR}
        -I${CMAKE_CURRENT_SOURCE_DIR}/swigfiles
    )

    MY_SWIG_ADD_MODULE( ${TARGET} tcl ${INTERFACE_FILE} )
    SWIG_LINK_LIBRARIES( ${TARGET} ${TARGET_BASE} ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY} ${SYS_LIBS} )
    SET_TARGET_PROPERTIES( ${TARGET} PROPERTIES PREFIX "" )

    # Install the configuration specific Tcl package index file and all other Tcl files.
    INSTALL_TCL_PACKAGE( ${TARGET} "tclfiles/pkgIndex.tcl.in" "tclfiles/" "tcl3d*.tcl" )

    # Install the shared library containing the SWIG generated wrapper.
    INSTALL(
        TARGETS     ${TARGET}
        DESTINATION ${TCL3D_INST_DIR}/${TARGET}
    )
ENDIF( TCL3D_BUILD_GL2PS )
