PROJECT(ossimQt)
MESSAGE("**********************Setting up ossimq_qt4********************")
INCLUDE(OssimVersion)
INCLUDE(OssimUtilities)
INCLUDE(OssimCommonVariables)
INCLUDE(OssimQt4Macros)

SET (QT_MIN_VERSION "4.2.2")
SET(QT_USE_QT3SUPPORT "ON")

FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project
INCLUDE(${QT_USE_FILE})
SET(QT_USE_QTOPENGL ON)
find_package(Qt4)

find_package(OpenThreads)
find_package(ossim)
find_package(TIFF)

ADD_DEFINITIONS(${QT_DEFINITIONS}
	-DQT_CORE_LIB
	-DQT_GUI_LIB
	-DQT_QT3SUPPORT_LIB
	-DQT_THREAD_SUPPORT
)
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${OSSIM_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${QT_INCLUDES})
INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})

#MESSAGE(STATUS "QT_INCLUDES = ${QT_INCLUDES}")

############################################## BUILD THE LIBRARY ############################################
SET(LIB_NAME ossimQt)
FILE(GLOB OSSIMQT_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include/ossimQt/ossim*.h")
FILE(GLOB OSSIMQT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" )

LIST(REMOVE_ITEM OSSIMQT_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include/ossimQt/ossimQt4HistogramDialog.h")
LIST(REMOVE_ITEM OSSIMQT_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include/ossimQt/ossimQtMainWindow2.h")

LIST(REMOVE_ITEM OSSIMQT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossimQt4HistogramDialog.cpp")
LIST(REMOVE_ITEM OSSIMQT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/ossimQtMainWindow2.cpp")

MESSAGE("QT4_LIBRARIES === ${QT_LIBRARIES}")
QT4_WRAP_CPP(OSSIMQT_MOC_SRCS ${OSSIMQT_INCLUDES} )

SET(UI_DESTINATION_DIR ${${PROJECT_NAME}_SOURCE_DIR}/include/ossimQt)

SET(INCLUDE_DIR "include/ossimQt")
OSSIM_LINK_LIBRARY(${LIB_NAME} COMPONENT_NAME ossim TYPE "${OSSIM_USER_DEFINED_DYNAMIC_OR_STATIC}" HEADERS ${OSSIMQT_INCLUDES} SOURCE_FILES ${OSSIMQT_SRCS}  ${OSSIMQT_MOC_SRCS}
                   LIBRARIES ${OSSIM_LIBRARY} ${OSG_LIBRARY}  ${OPENTHREADS_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY} ${QT_LIBRARIES} ${TIFF_LIBRARIES}
                   INSTALL_LIB INSTALL_HEADERS VERSION_SYMLINKS ADDITIONAL_COMPILE_FLAGS "-DOSSIMQT_LIBRARY")

############################################# BUILD THE APPLICATIONS #################################################

QT4_ADD_RESOURCES(OSSIMQT_RC "${PROJECT_SOURCE_DIR}/apps/app.qrc")
set(TARGET_COMMON_LIBRARIES ossimQt)
FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/apps/imagelinker/imagelinker.cpp")
SET(OSSIM_BUILD_APPLICATION_BUNDLES ON)
MESSAGE(STATUS "IMAGELINKER SOURCE FILES = ${SOURCE_FILES}")
OSSIM_SETUP_APPLICATION(imagelinker INSTALL REQUIRE_WINMAIN_FLAG COMPONENT_NAME ossim SOURCE_FILES ${SOURCE_FILES} ${OSSIMQT_RC})

FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/apps/iview/iview.cpp")
SET(OSSIM_BUILD_APPLICATION_BUNDLES ON)
OSSIM_SETUP_APPLICATION(iview INSTALL REQUIRE_WINMAIN_FLAG COMPONENT_NAME ossim SOURCE_FILES ${SOURCE_FILES} ${OSSIMQT_RC})


########################### SETUP UNINSTALL ############################
OSSIM_ADD_COMMON_MAKE_UNINSTALL()
