PROJECT(xmms_projectM)
ADD_LIBRARY(xmms_projectM SHARED main.cpp sdltoprojectM.h video_init.cpp ConfigFile.h ConfigFile.cpp)

cmake_policy(SET CMP0005 OLD)
cmake_minimum_required(VERSION 2.4.0)

INCLUDE(FindPkgConfig.cmake)

INCLUDE(cmake/CPack-projectM.cmake)

FIND_PACKAGE(OpenGL)
FIND_PACKAGE(GTK)
FIND_PACKAGE(SDL)

pkg_search_module(LIBXMMS REQUIRED libxmms)

if(LIBXMMS_FOUND)
MESSAGE(FATAL_ERROR "Xmms not found.")
else(LIBXMMS_FOUND)
MESSAGE(STATUS "Xmms detected.")
endif(LIBXMMS_FOUND)

if (${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME})
	pkg_search_module(LIBPROJECTM REQUIRED libprojectM)
	ADD_DEFINITIONS(-DLINUX -DPROJECTM_PREFIX='\"${LIBPROJECTM_PREFIX}\"')
else (${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME})
	set(LIBPROJECTM_FOUND true)
	ADD_DEFINITIONS(-DLINUX -DPROJECTM_PREFIX='\"${CMAKE_INSTALL_PREFIX}\"')
endif(${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME})

ADD_DEFINITIONS(-DLINUX -DPROJECTM_PREFIX='\"${PROJECTM_PREFIX}\"')

if (${CMAKE_PROJECT_NAME} MATCHES "projectM-complete")
   set(PROJECTM_INCLUDE ${PROJECTM_ROOT_SOURCE_DIR}/libprojectM)
   set(PROJECTM_LINK ${PROJECTM_ROOT_BINARY_DIR}/libprojectM)
elseif (${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME})
   set(PROJECTM_INCLUDE ${LIBPROJECTM_INCLUDEDIR}/libprojectM)
   set(PROJECTM_LINK ${LIBPROJECTM_LDFLAGS})
endif (${CMAKE_PROJECT_NAME} MATCHES "projectM-complete")

INCLUDE_DIRECTORIES(${PROJECTM_INCLUDE} ${LIBXMMS_INCLUDEDIR} ${SDL_INCLUDE_DIR} ${GTK_INCLUDE_DIR})

LINK_DIRECTORIES(${PROJECTM_LINK} ${LIBXMMS_LDFLAGS})

TARGET_LINK_LIBRARIES(xmms_projectM projectM xmms ${SDL_LIBRARY} ${GTK_LIBRARIES})

INSTALL(TARGETS xmms_projectM DESTINATION lib/xmms/Visualization )
