cmake is now build the kernel drivers properly

This commit is contained in:
Markus Rosenstihl 2017-01-20 09:58:42 +00:00
parent e73407f64c
commit 10c2f2d70c
3 changed files with 33 additions and 10 deletions

View File

@ -9,7 +9,7 @@ set(SPC_HEADERS
include/spcm_drv.h) include/spcm_drv.h)
add_custom_command(OUTPUT ${SPC_HEADERS} 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} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Unpacking SPC headers" COMMENT "Unpacking SPC headers"
VERBATIM) VERBATIM)

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
# unpack headers needed
set( SPC_DRV drv_header_v402b6844.zip) set( SPC_DRV drv_header_v402b6844.zip)
set(SPC_HEADERS set(SPC_HEADERS
include/spcerr.h include/spcerr.h
@ -8,10 +10,31 @@ set(SPC_HEADERS
include/spcioctl.inc) include/spcioctl.inc)
add_custom_command(OUTPUT ${SPC_HEADERS} 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} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Unpacking SPC headers" COMMENT "Unpacking SPC headers"
VERBATIM) 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}) add_library(Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${SPC_HEADERS})

View File

@ -1,20 +1,20 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
Set( DRIVER_FILE pulseblaster.ko ) # Creating pulseblaster kernel module
# set(DRIVER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/pulseblaster.ko )
#Set( DRIVER_BIN_FILE ../pulseblaster.ko ) set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" )
Set( KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" ) set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
Set( KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
-C ${KERNEL_DIR} -C ${KERNEL_DIR}
M=${CMAKE_CURRENT_SOURCE_DIR} modules) M=${CMAKE_CURRENT_SOURCE_DIR} modules)
add_custom_command( OUTPUT ${DRIVER_FILE} add_custom_command(OUTPUT ${DRIVER_FILE}
COMMAND ${KBUILD_CMD} COMMAND ${KBUILD_CMD}
# COMMAND cp -f ${DRIVER_FILE} ${DRIVER_BIN_FILE} # COMMAND cp -f ${DRIVER_FILE} ${DRIVER_BIN_FILE}
COMMENT "Building pulseblaster.ko"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 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(..) #include_directories(..)
add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp) add_library(SpinCore-PulseBlaster SpinCore-PulseBlaster.cpp)