project(SpanCPTComponent)

################################################################################
add_definitions( -DCPTCOMPONENT_EXPORTS )
add_definitions( -DPLUGINLIB_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}
)


pacpus_plugin(PLUGIN_CPP PLUGIN_H ${PROJECT_NAME} )

# ========================================
# List of sources
# ========================================
set(
    PROJECT_SRCS
	CPTComponent.h
	CPTComponent.cpp
    ../driver/AbstractSerialPort.h
    ../driver/AbstractSerialPort.cpp
    ${PLUGIN_CPP}
)

if(WIN32)
set(PROJECT_SRCS 
  ${PROJECT_SRCS}
  ../driver/Win32SerialPort.cpp
  ../driver/Win32SerialPort.h
)
endif(WIN32)

if(UNIX)
set(PROJECT_SRCS 
  ${PROJECT_SRCS}
  ../driver/PosixSerialPort.cpp
  ../driver/PosixSerialPort.h
  )
endif(UNIX)


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

if(UNIX)
set(FILES_TO_MOC 
  # add here the header files that you want to MOC
  CPTComponent.h
  ../driver/PosixSerialPort.h
    ${PLUGIN_H}
  )
endif(UNIX)

if(WIN32)
set(FILES_TO_MOC 
  # add here the header files that you want to MOC
  CPTComponent.h
  ../driver/Win32SerialPort.h
    ${PLUGIN_H}
  )
endif(WIN32)

set(
    UI_FILES
)

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

qt4_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 NMEA0183LIB debug NMEA0183LIB_d
		optimized PacpusTools debug PacpusTools_d
    )
endif(WIN32)

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

    )
endif(UNIX)

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

# ========================================
# Install
# ========================================
pacpus_install(${PROJECT_NAME})

