PROJECT(BALLView)

### list all filenames of the directory here ###
SET(SOURCES_LIST
	demoTutorialDialog.C
	icons.C
	main.C
	mainframe.C
)

### the list of all files requiring a moc run ###
SET(MOC_SOURCES_LIST
	demoTutorialDialog.h
	mainframe.h
)

SET(UI_SOURCES_LIST
	aboutDialog.ui
	demoTutorialDialog.ui
)

SET(RCC_SOURCES_LIST
	splashscreen.qrc
)

SET(RESOURCES_LIST
	BALLView.rc
)

IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
	LIST(APPEND RESOURCES_LIST ${CMAKE_SOURCE_DIR}/cmake/installer/BALLView.icns)
	SET(MACOSX_BUNDLE_ICON_FILE BALLView.icns)
	SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/cmake/installer/BALLView.icns
			PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
ENDIF()

QT4_WRAP_CPP(MOC_OUTFILES ${MOC_SOURCES_LIST})
QT4_ADD_RESOURCES(RCC_OUTFILES ${RCC_SOURCES_LIST})
QT4_WRAP_UI(UIC_OUTFILES ${UI_SOURCES_LIST})

INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

ADD_EXECUTABLE(BALLView
	${SOURCES_LIST}
	${MOC_OUTFILES}
	${RCC_OUTFILES}
	${UIC_OUTFILES}
	${RESOURCES_LIST}
)

IF (WIN32)
	SET_TARGET_PROPERTIES(BALLView PROPERTIES WIN32_EXECUTABLE TRUE)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
	SET_TARGET_PROPERTIES(BALLView PROPERTIES MACOSX_BUNDLE TRUE)
ENDIF()

INSTALL(TARGETS BALLView
	COMPONENT "${COMPONENT_BALLVIEW}"
	RUNTIME DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
	BUNDLE DESTINATION "${BALL_BUNDLE_INSTALL_DIRECTORY}"
)

INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/internal 
	DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}" 
	COMPONENT "${COMPONENT_BALLVIEW}"
)

INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/BALLView 
	DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}" 
	COMPONENT "${COMPONENT_BALLVIEW}"
)

IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
	GET_FILENAME_COMPONENT(MACDEPLOYQT_EXECUTABLE "${QT_QMAKE_EXECUTABLE}" PATH)
	SET(MACDEPLOYQT_EXECUTABLE "${MACDEPLOYQT_EXECUTABLE}/macdeployqt")
	INSTALL(CODE "SET(MACDEPLOYQT_EXECUTABLE \"${MACDEPLOYQT_EXECUTABLE}\")" COMPONENT "${COMPONENT_BALLVIEW}")
	INSTALL(CODE "SET(FIXBUNDLE ${CMAKE_SOURCE_DIR}/MacOSX/fixbundleframeworks.sh)" COMPONENT "${COMPONENT_BALLVIEW}")
	INSTALL(CODE "SET(BALLVIEW_BUNDLE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BALL_BUNDLE_INSTALL_DIRECTORY}/BALLView.app\")" COMPONENT "${COMPONENT_BALLVIEW}")
	INSTALL(CODE "SET(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})" COMPONENT "${COMPONENT_BALLVIEW}")
	INSTALL(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/BALLViewCreateBundle.cmake" COMPONENT "${COMPONENT_BALLVIEW}")
ENDIF()

SET(BALLVIEW_SUPPORT_LIBRARIES "")
IF (UNIX)
	LIST(APPEND BALLVIEW_SUPPORT_LIBRARIES "pthread")
ENDIF ()

TARGET_LINK_LIBRARIES(BALLView BALL VIEW ${BALLVIEW_SUPPORT_LIBRARIES})

#Setup the translations
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/BALLViewTranslations.cmake)
