project(qonjugatorlib)
cmake_minimum_required(VERSION 2.6)

### don't create the uninstall rule if this library is compiled as part of the Qonjugator package
if (qonjugator_compile_not_standalone)
    set(qonjugator_uninstall_rule_created TRUE)
endif (qonjugator_compile_not_standalone)

### include application defaults
include(../ConfigureDefaults.cmake)

### find the Qt4 library and set some useful definitions
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_NO_DEBUG -DQT_SHARED)
add_definitions(-DQONJ_INSTALL_PLUGINS=\"${QONJUGATOR_PLUGINSDIR}\")
add_definitions(-DQONJ_INSTALL_TRANSLATIONS=\"${QONJUGATOR_TRANSLATIONSDIR}\")

### tell the user where we will install everything
message("Qonjugator Library")
message("   The library will be installed in ${QONJUGATOR_LIBDIR}")
message("   The header files will be installed in ${QONJUGATOR_INCLUDESDIR}")

### compile
set(qonjugatorlib_SRCS
    qonjugatorcontroller.cpp)
set(qonjugatorlib_MOC_HDRS
    qonjugatorcontroller.h)
qt4_wrap_cpp(qonjugatorlib_MOC_SRCS
             ${qonjugatorlib_MOC_HDRS})

add_library(qonjugatorcore
            SHARED
            ${qonjugatorlib_SRCS} ${qonjugatorlib_MOC_SRCS})
target_link_libraries(qonjugatorcore
                      ${QT_LIBRARIES})

### install
install(TARGETS qonjugatorcore
        LIBRARY DESTINATION ${QONJUGATOR_LIBDIR})
install(FILES qonjugatorcontroller.h qonjugatorplugin.h qonjugatortense.h
        DESTINATION ${QONJUGATOR_INCLUDESDIR})
install(FILES FindQonjugatorLib.cmake
        DESTINATION ${CMAKE_ROOT}/Modules)

### uninstall
if (NOT qonjugator_uninstall_rule_created)
	set(qonjugator_uninstall_rule_created TRUE)
	configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../cmake_uninstall.cmake.in"
	               "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
	               IMMEDIATE @ONLY)
	add_custom_target(uninstall
	                  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
endif(NOT qonjugator_uninstall_rule_created)
