cmake_minimum_required(VERSION 2.6)
project(spmod_collage)

find_package(POCO)
find_package ( SDL REQUIRED )
find_package ( SDL_image REQUIRED )
find_package ( SDL_gfx REQUIRED )

set(spmod_collage_SRCS
	mod_collage.cpp
)

#set (mod_collage_gui_SRCS
#	config_gui.h
#	config_gui.cpp
#)

include_directories (${SDL_INCLUDE_DIR})
include_directories (${SDLIMAGE_INCLUDE_DIR})
include_directories (${SDLGFX_INCLUDE_DIR})

include_directories (${POCO_INCLUDE_DIR})
include_directories (${POCO_XML_INCLUDE_DIR})

# Base library
add_library (spmod_collage MODULE ${spmod_collage_SRCS})
target_link_libraries(spmod_collage spcore)
target_link_libraries(spmod_collage mod_XMLImplementation)
target_link_libraries(spmod_collage mod_Pictures)
target_link_libraries(spmod_collage mod_Kernel)
#target_link_libraries(spmod_collage mod_collage_gui)

target_link_libraries(spmod_collage ${SDL_LIBRARY})
target_link_libraries(spmod_collage ${SDLIMAGE_LIBRARY})
target_link_libraries(spmod_collage ${SDLGFX_LIBRARY})

target_link_libraries(spmod_collage ${POCO_XML_LIBRARY})


# Base gui library
#add_library (mod_collage_gui STATIC ${mod_collage_gui_SRCS})
#target_link_libraries(mod_collage_gui spcore)
#target_link_libraries(mod_collage_gui ${wxWidgets_LIBRARIES})

add_subdirectory(XMLImplementation)
add_subdirectory(Pictures)
add_subdirectory(Kernel)

IF(BUILD_TESTS)
	ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTS)

INSTALL (TARGETS spmod_collage RUNTIME DESTINATION ${LIBRUNTIMEDIR} LIBRARY DESTINATION ${PLUGINDIR})
IF (WIN32)
	FIND_PATH (SDL_image_RUNTIME_LIBS_DIR SDL_image.dll
		HINTS
		$ENV{SDLIMAGEDIR}
		PATH_SUFFIXES lib64 lib
		PATHS)
	FILE (GLOB SDL_image_RUNTIME_LIBS ${SDL_image_RUNTIME_LIBS_DIR}/*.dll)
	
	INSTALL (PROGRAMS ${SDL_image_RUNTIME_LIBS} DESTINATION ${LIBRUNTIMEDIR})
	
	FIND_PATH (SDL_gfx_RUNTIME_LIBS_DIR SDL_gfx.dll
		HINTS
		$ENV{SDLGFXDIR}
		PATH_SUFFIXES lib64 lib
		PATHS)
	FILE (GLOB SDL_gfx_RUNTIME_LIBS ${SDL_gfx_RUNTIME_LIBS_DIR}/*.dll)
	
	INSTALL (PROGRAMS ${SDL_gfx_RUNTIME_LIBS} DESTINATION ${LIBRUNTIMEDIR})
ENDIF (WIN32)

if(WIN32)
	find_file (POCO_XML_RUNTIMED bin/PocoXMLd.dll HINTS $ENV{POCO_ROOT})
	find_file (POCO_XML_RUNTIME bin/PocoXML.dll HINTS $ENV{POCO_ROOT})
	if (MSVC)
		install_to_msvc_build_directory("${EXECUTABLE_OUTPUT_PATH}" "${POCO_XML_RUNTIMED}")
	endif(MSVC)
	
	install(FILES ${POCO_XML_RUNTIMED} DESTINATION "${BINDIR}" CONFIGURATIONS Debug)
	install(FILES ${POCO_XML_RUNTIME} DESTINATION "${BINDIR}" CONFIGURATIONS Release RelWithDebInfo)
endif(WIN32)
