######################
#
#    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
#
#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Lesser General Public
#    License as published by the Free Software Foundation; either
#    version 2.1 of the License, or (at your option) any later version.
#
#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Lesser General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public
#    License along with this library; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#    MA 02110-1301  USA.
#
######################

INCLUDE_DIRECTORIES(
  ${QT_INCLUDES}
  ${CMAKE_CURRENT_BINARY_DIR}
	${CMAKE_CURRENT_SOURCE_DIR}
	${libsiweather_SOURCE_DIR}
	${libsiweather_BINARY_DIR}
	${LIBENGSAS_INCLUDE_DIR}
)
SET(LINK_LIBRARIES
	${QT_LIBRARIES}
	libsiweather
	${LIBENGSAS_LIBRARIES}
)

SET(src_CPP
	main.cpp
)

CONFIGURE_FILE(siweatherclientconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/siweatherclientconfig.h)
# needed to compile the icon into the exe file
# the MINGW part is a workaround, since mingw can not handle the rc file
# (msvc can handle it)
# IF(WIN32)
	# IF( MINGW )
		# resource compilation for MinGW
		# ADD_CUSTOM_COMMAND(
			# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/epartexeico.o
			# COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/epartexe.rc
			# -o ${CMAKE_CURRENT_BINARY_DIR}/epartexeico.o
		# )
		# SET(src_CPP ${src_CPP} ${CMAKE_CURRENT_BINARY_DIR}/epartexeico.o)
	# ELSE( MINGW )
		# SET(src_CPP ${src_CPP} epartexe.rc)
	# ENDIF( MINGW )
# ENDIF(WIN32)


SET(neededStuff ${src_CPP})

IF(UNIX)
 	ADD_EXECUTABLE(siweatherstation ${neededStuff})
ELSEIF(APPLE)
	# it's with gui, so MACOSX_BUNDLE is needed
	ADD_EXECUTABLE(siweatherstation ${neededStuff})
ELSEIF(WIN32)
  # it's with gui, so WIN32 is needed
  ADD_EXECUTABLE(siweatherstation ${neededStuff})
	SET_TARGET_PROPERTIES(siweatherstation PROPERTIES DEBUG_POSTFIX d)
ENDIF()

TARGET_LINK_LIBRARIES(siweatherstation ${LINK_LIBRARIES})

qt5_use_modules(siweatherstation Core)

# The COMPONENT option only defines the internal belonging of the INSTALL'ed thing
INSTALL(
  TARGETS siweatherstation
  RUNTIME DESTINATION ${bin_DIR}
  COMPONENT application
)
