#########################quick start############################################
#cmake ../ -G "CodeBlocks - Unix Makefiles"
#make
#make install
#make clean
################################################################################
project(Gps)
set(${PROJECT_NAME}_VERSION_MAJOR 0)
set(${PROJECT_NAME}_VERSION_MINOR 1)
add_definitions( -DGPS_EXPORTS )
################################################################################
create_export(EXPORT_HDR ${PROJECT_NAME})
pacpus_plugin(PLUGIN_CPP PLUGIN_HDR ${PROJECT_NAME})
add_definitions (${QT_DEFINITIONS})

find_package(Qt5Network REQUIRED)
find_package(Qt5Widgets REQUIRED)
################################################################################
# DIRECTORIES
include_directories( 
    ${PROJECT_BINARY_DIR}
    ${QT_INCLUDE_DIR}
    ${PACPUS_INCLUDE_DIR}
    ${PACPUS_INCLUDE_DIR}/Pacpus/
)

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


################################################################################
# FILES
set(PROJECT_HDRS
    ${EXPORT_HDR}
    gpsComponent.h
    GpsFrames.h
    SeptentrioSocket.h
    SbfFrames.h
    structure_gps.h
    gps_nmea.xml 
)
set(PROJECT_SRCS
    ${PLUGIN_CPP}
    gpsComponent.cpp 
    SeptentrioSocket.cpp
    ui/polarxmainwindow.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)

if(UNIX)
set(FILES_TO_MOC 
  # add here the header files that you want to MOC
  gpsComponent.h
  GpsFrames.h
  #SeptentrioComponent.h
  SeptentrioSocket.h  
  ../driver/PosixSerialPort.h
  ui/polarxmainwindow.hpp
  ${PLUGIN_HDR}
  )
endif(UNIX)

if(WIN32)
set(FILES_TO_MOC 
  # add here the header files that you want to MOC
  gpsComponent.h
  # SeptentrioComponent.h
  # SeptentrioSocket.h    
  ../driver/Win32SerialPort.h
  #  ui/polarxmainwindow.hpp
  ${PLUGIN_HDR}
  )
endif(WIN32)

set(UI_FILES
)

################################################################################
# Qt: call moc, uic
qt_wrap_cpp(PROJECT_MOC_SRCS
    ${FILES_TO_MOC}
)

qt_wrap_ui(PROJECT_UI_SRCS
    ${UI_FILES}
)

################################################################################
# BUILD and LINK
pacpus_add_library(${PROJECT_NAME} SHARED
    ${PROJECT_HDRS}
    ${PROJECT_SRCS}
    ${PROJECT_MOC_SRCS}
    ${PROJECT_UI_SRCS}
)


# ========================================
# Libraries
# ========================================
set(LIBS
    optimized FileLib debug FileLib_d
    optimized PacpusLib debug PacpusLib_d
    optimized PacpusTools debug PacpusTools_d
    optimized NMEA0183LIB debug NMEA0183LIB_d
)
if (WIN32)
    list(APPEND LIBS 
        optimized ROAD_TIME debug ROAD_TIME_d
    )
endif()
# LINK 
target_link_libraries(${PROJECT_NAME} 
		      ${PACPUS_LIBRARIES} 
	              ${PACPUS_DEPENDENCIES_LIB} 
                      ${LIBS}
                      ${QT_LIBRARIES}  
                     )
qt5_use_modules(${PROJECT_NAME} Network)
################################################################################
# FOLDERS
pacpus_folder(${PROJECT_NAME} "components")
################################################################################
# INSTALL
pacpus_install(${PROJECT_NAME}) 
