cmake_minimum_required(VERSION 3.0)

# Creating pulseblaster kernel module
set(DRIVER_FILE  ${CMAKE_CURRENT_SOURCE_DIR}/pulseblaster.ko )
set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" )
set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
               -C ${KERNEL_DIR}
               M=${CMAKE_CURRENT_SOURCE_DIR} modules)

add_custom_command(OUTPUT ${DRIVER_FILE}
                   COMMAND ${KBUILD_CMD}
#                   COMMAND cp -f ${DRIVER_FILE} ${DRIVER_BIN_FILE}
                   COMMENT "Building pulseblaster.ko"
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                   VERBATIM)

add_custom_target(pulseblaster_drv ALL DEPENDS ${DRIVER_FILE} )

#include_directories(..)
add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp)
add_library(PulseBlasterProgram PulseBlasterProgram.cpp)
