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
)

QT5_WRAP_UI(UIC_OUTFILES ${UI_SOURCES_LIST})

SET(BALLVIEW_DEP_LIBRARIES BALL VIEW Qt5::Widgets)

IF(APPLE)
	SET(BALLVIEW_EXEC_PROPERTY MACOSX_BUNDLE)
	SET(MACOSX_BUNDLE_ICON_FILE BALLView.icns)
	SET(RESOURCES_LIST ${PROJECT_SOURCE_DIR}/BALLView.icns ${CMAKE_SOURCE_DIR}/LICENSE)
	SET_SOURCE_FILES_PROPERTIES(${RESOURCES_LIST} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
ELSEIF(WIN32)
	SET(BALLVIEW_EXEC_PROPERTY WIN32)
	SET(RESOURCES_LIST BALLView.rc)
ELSEIF(UNIX)
	LIST(APPEND BALLVIEW_DEP_LIBRARIES "pthread" "X11")
ENDIF()

INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
ADD_DEFINITIONS(${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS})

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

TARGET_LINK_LIBRARIES(BALLView ${BALLVIEW_DEP_LIBRARIES})

#Setup the translations
INCLUDE(BALLViewTranslations)

IF(APPLE)
	IF(QT_DEPLOY_EXECUTABLE)
		CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/BALLViewInstallFix.cmake.in ${PROJECT_BINARY_DIR}/BALLViewInstallFix.cmake @ONLY)
		INSTALL(SCRIPT ${PROJECT_BINARY_DIR}/BALLViewInstallFix.cmake)
	ENDIF()
ELSE()
	INSTALL(TARGETS BALLView
		COMPONENT "${COMPONENT_BALLVIEW}"
		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
		BUNDLE DESTINATION "${BALL_BUNDLE_INSTALL_DIRECTORY}"
	)

	IF(WIN32)
		IF(QT_DEPLOY_EXECUTABLE)
			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/BALLView.exe)"
				COMPONENT "${COMPONENT_BALLVIEW}")
		ENDIF()
	ENDIF()
ENDIF()

