From 10c2f2d70c2c97a5d6a4c3b74aadb130e83c6b71 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Fri, 20 Jan 2017 09:58:42 +0000 Subject: [PATCH] cmake is now build the kernel drivers properly --- drivers/Spectrum-M2i40xxSeries/CMakeLists.txt | 2 +- drivers/Spectrum-MI40xxSeries/CMakeLists.txt | 25 ++++++++++++++++++- drivers/SpinCore-PulseBlaster/CMakeLists.txt | 16 ++++++------ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt b/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt index 36d571d..6a1c9bb 100644 --- a/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt +++ b/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt @@ -9,7 +9,7 @@ set(SPC_HEADERS include/spcm_drv.h) add_custom_command(OUTPUT ${SPC_HEADERS} - COMMAND unzip -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/ + COMMAND unzip -o -q -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Unpacking SPC headers" VERBATIM) diff --git a/drivers/Spectrum-MI40xxSeries/CMakeLists.txt b/drivers/Spectrum-MI40xxSeries/CMakeLists.txt index 40f71eb..43d420d 100644 --- a/drivers/Spectrum-MI40xxSeries/CMakeLists.txt +++ b/drivers/Spectrum-MI40xxSeries/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.0) + +# unpack headers needed set( SPC_DRV drv_header_v402b6844.zip) set(SPC_HEADERS include/spcerr.h @@ -8,10 +10,31 @@ set(SPC_HEADERS include/spcioctl.inc) add_custom_command(OUTPUT ${SPC_HEADERS} - COMMAND unzip -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/ + COMMAND unzip -o -q -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Unpacking SPC headers" VERBATIM) +# Creating spc kernel module if the folder +set(SPC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv) +set(DRIVER_FILE ${SPC_SRC}/spc_smp.ko ) +set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" ) +set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM} + -C ${KERNEL_DIR} + M=${SPC_SRC} modules) + +#unset(spc_src CACHE) +#find_file(spc_src ) + +add_custom_command(OUTPUT ${DRIVER_FILE} + COMMAND ${KBUILD_CMD} + COMMENT "Building spc_smp.ko" + WORKING_DIRECTORY ${SPC_SRC} + VERBATIM) +if(EXISTS ${CMAKE_SOURCE_DIR}/drivers/Spectrum-MI40xxSeries/linux) +add_custom_target (micx_drv ALL DEPENDS ${DRIVER_FILE} ) +else() + message(Spectrum MI40xx dirver not found, unpack and configure it) +endif() add_library(Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${SPC_HEADERS}) diff --git a/drivers/SpinCore-PulseBlaster/CMakeLists.txt b/drivers/SpinCore-PulseBlaster/CMakeLists.txt index a7507b1..b3de4fb 100644 --- a/drivers/SpinCore-PulseBlaster/CMakeLists.txt +++ b/drivers/SpinCore-PulseBlaster/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.0) -Set( DRIVER_FILE pulseblaster.ko ) -# -#Set( DRIVER_BIN_FILE ../pulseblaster.ko ) -Set( KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" ) -Set( KBUILD_CMD ${CMAKE_MAKE_PROGRAM} +# 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} +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} - DEPENDS ${src} Kbuild VERBATIM ) + VERBATIM) -add_custom_target ( driver DEPENDS ${DRIVER_FILE} ) +add_custom_target(pulseblaster_drv ALL DEPENDS ${DRIVER_FILE} ) #include_directories(..) add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp)