PROJECT(QueEasyRun)

FIND_PACKAGE(Qwt5)

IF(NOT Qwt5_Qt4_FOUND)
	RETURN()
ENDIF()

### list all filenames of the directory here ###
SET(SOURCES_LIST
#	featureSelector.C
#	inputPartitioner.C
#	inputReader.C
	main.C
#	modelCreator.C
#	predictor.C
#	validator.C
)

IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# TODO: Use an icon for QuEasy
	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()

INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR} ${Qwt5_INCLUDE_DIR})

ADD_DEFINITIONS(-DEXT_MAIN)

ADD_EXECUTABLE(QuEasyRun
	${SOURCES_LIST}
	${RESOURCES_LIST}
)

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

TARGET_LINK_LIBRARIES(QuEasyRun BALL ${Qwt5_Qt4_LIBRARY})

INSTALL(TARGETS QuEasyRun
	COMPONENT "${COMPONENT_QUEASY}"
	RUNTIME DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
	BUNDLE DESTINATION "${BALL_BUNDLE_INSTALL_DIRECTORY}"
)

#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/QuEasyRun
#	DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}" 
#	COMPONENT "${COMPONENT_QUEASY}"
#)

#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_QUEASY}")
	INSTALL(CODE "SET(FIXBUNDLE ${CMAKE_SOURCE_DIR}/MacOSX/fixbundleframeworks.sh)" COMPONENT "${COMPONENT_QUEASY}")
	INSTALL(CODE "SET(BALLVIEW_BUNDLE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BALL_BUNDLE_INSTALL_DIRECTORY}/QuEasyRun.app\")" COMPONENT "${COMPONENT_QUEASY}")
	INSTALL(CODE "SET(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})" COMPONENT "${COMPONENT_QUEASY}")
	INSTALL(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/BALLViewCreateBundle.cmake" COMPONENT "${COMPONENT_QUEASY}")
ENDIF()

TARGET_LINK_LIBRARIES(QuEasyRun BALL VIEW)
