cmake_minimum_required(VERSION 3.0)

include(FindPkgConfig)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")


#pkg_check_modules (XERCES xerces-c REQUIRED)
#include_directories(.. ${XERCES_INCLUDE_DIRS})
#link_directories(${XERCES_LIBRARY_DIRS})


#find_library(PB24 SpinCore-PulseBlaster24Bit PATH ${CMAKE_SOURCE_DIR})
link_directories(../drivers/SpinCore-PulseBlaster24Bit
        ../drivers/SpinCore-PulseBlaster
        ../drivers/SpinCore-PulseBlasterDDSIII
        ../drivers)

set(PB24 SpinCore-PulseBlaster24Bit SpinCore-PulseBlaster PulseBlasterProgram)
set(PBDDS SpinCore-PulseBlasterDDSIII SpinCore-PulseBlaster PulseBlasterProgram)

add_executable(dummycore dummycore.cpp hardware.cpp)
target_link_libraries(dummycore pthread ${XERCES_LIBRARIES} core dummy tempcont Eurotherm-2000Series)
install(TARGETS dummycore DESTINATION lib/damaris/backends)

add_executable(berta berta.cpp hardware.cpp)
target_link_libraries(berta pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS  )
install(TARGETS berta DESTINATION lib/damaris/backends)

add_executable(birgit birgit.cpp hardware.cpp)
target_link_libraries(birgit pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS  )
install(TARGETS birgit DESTINATION lib/damaris/backends)

add_executable(bg_backend bg_backend.cpp hardware.cpp)
target_link_libraries(bg_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS  )

add_executable(Mobilecore Mobilecore.cpp hardware.cpp)
target_link_libraries(Mobilecore pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS  )

add_executable(Mobilecore_wo_sync_backend Mobile_wo_sync_backend.cpp hardware.cpp)
target_link_libraries(Mobilecore_wo_sync_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS  )

add_executable(deuteron_backend deuteron_backend.cpp hardware.cpp)
target_link_libraries(deuteron_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} ${PBDDS} PTS  )

add_executable(PFGcore PFGcore.cpp hardware.cpp)
target_link_libraries( PFGcore pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 )


add_executable(fc1neu_backend fc1neu_backend.cpp hardware.cpp)
target_link_libraries( fc1neu_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 )

# spcm linux driver needs to be installed (see http://spectrum-instrumentation.com/de/downloads/drivers)
#include_directories(${CMAKE_SOURCE_DIR}/drivers/Spectrum-M2i40xxSeries/include)
#add_executable(fc1_vierkanal_backend fc1_vierkanal_backend.cpp hardware.cpp)
#target_link_libraries( fc1_vierkanal_backend pthread ${XERCES_LIBRARIES} core spcm_linux Spectrum-M2i40xxSeries ${PB24} PTS DAC20 )

add_executable(fc2_backend fc2_backend.cpp hardware.cpp)
target_link_libraries( fc2_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 )

add_executable(fc2_AD5791_backend fc2_backend_AD5791.cpp hardware.cpp)
target_link_libraries( fc2_AD5791_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 )

add_executable(general general.cpp hardware.cpp)
target_link_libraries( general pthread ${XERCES_LIBRARIES} ${GLIB2_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 )

add_executable(magnexgrad_backend magnexgrad_backend.cpp hardware.cpp)
target_link_libraries( magnexgrad_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PB24} PTS DAC20 tempcont Eurotherm-2000Series)

add_executable(magnexgrad_dds_backend magnexgrad_backend_dds.cpp hardware.cpp)
target_link_libraries( magnexgrad_dds_backend pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries ${PBDDS} PTS DAC20 tempcont Eurotherm-2000Series)

add_executable(pulseblaster_only pulseblaster_only.cpp hardware.cpp)
target_link_libraries(pulseblaster_only pthread ${XERCES_LIBRARIES} core ${PB24} PTS dummy DAC20 tempcont Eurotherm-2000Series )
install(TARGETS dummycore
        berta
        birgit
        bg_backend
        Mobilecore
        Mobilecore_wo_sync_backend
        deuteron_backend
        fc1neu_backend
        PFGcore
        fc2_backend
        fc2_AD5791_backend
        general
        magnexgrad_backend
        magnexgrad_dds_backend
        pulseblaster_only
        DESTINATION lib/damaris/backends)

