######################################################################################################
#
#  created:    2015/09/18
#  filename:   CMakeLists.txt
#
#  author:     Gerald Dherbomez
#              Copyright Heudiasyc (c) UMR UTC/CNRS 7253
# 
#  license:    CECILL-C
# 
#  version:    $Id: $
#
#  brief:      Pacpus project template 
#
######################################################################################################


################################################################################
project(PluginTemplate)
################################################################################

# The following definition is useful for Windows OS
# It is used to declare dllimport and dllexport
add_definitions( -DPLUGINTEMPLATE_EXPORTS )

# ========================================
# Configure qt4
# ========================================
if(QT4_FOUND)
  set(QT_USE_QTXML true)
  set(QT_USE_QTNETWORK true)
  include(${QT_USE_FILE})
else()
  message(ERROR "Qt4 needed")
endif()

# ========================================
# Compiler definitions
# ========================================
add_definitions(
  ${QT_DEFINITIONS}
)

# ========================================
# Include directories
# ========================================
include_directories(
  ${PROJECT_BINARY_DIR}
  ${QT_INCLUDE_DIR}
)

# ========================================
# Link directories
# ========================================
link_directories( 
	${PACPUS_LIB_DIR}
)


# Create the pacpus plugin
pacpus_plugin(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )

# ========================================
# List of sources
# ========================================
set(
    PROJECT_SRCS
    # Add your source files, at least one pacpus component cpp file 
    # See component_template
    #
	# YourComponent.cpp
    ${PLUGIN_CPP}
)

if(WIN32)
    list(APPEND PROJECT_SRCS
        # if needed add your specific source files for Windows OS
        #SpecificWin32SourceFile.cpp
    )
endif(WIN32)
if(UNIX)
    list(APPEND PROJECT_SRCS
        # if needed add your specific source files for Linux OS
        #SpecificLinuxSourceFile.cpp
    )
endif(UNIX)

# ========================================
# Files to MOC
# ========================================

set(
    FILES_TO_MOC
    # Add your header files that need to be MOCed (check Qt doc about MOCing)
    # at least, put the pacpus component header file 
    # See component_template
    #
	# YourComponent.h
    ${PLUGIN_H}
)

set(
    UI_FILES
)

# ========================================
# Call MOC
# ========================================
qt_wrap_cpp(
    PROJECT_MOC_SRCS
    ${FILES_TO_MOC}
)

qt_wrap_ui(
    PROJECT_UI_SRCS
    ${UI_FILES}
)

# ========================================
# Build a library
# ========================================
pacpus_add_library(
    ${PROJECT_NAME} SHARED
    ${PROJECT_SRCS}
    ${PROJECT_MOC_SRCS}
    ${PROJECT_UI_SRCS}
)

# ========================================
# Libraries
# ========================================
if(WIN32)
    set(LIBS
        # add your specific libraries to link here
		# optimized yourlib.lib debug yourlib_debug.lib
    )
endif(WIN32)

if(UNIX)
    set(LIBS
        # add your specific libraries to link here
        # youlib
    )
endif(UNIX)

# All the platform
target_link_libraries(
    ${PROJECT_NAME}
    ${PACPUS_LIBRARIES}
    ${QT_LIBRARIES}
	${PACPUS_DEPENDENCIES_LIB}
	${LIBS}
)
pacpus_folder(${PROJECT_NAME} "components")

# ========================================
# Install
# ========================================
# install plugin
pacpus_install(${PROJECT_NAME}
