83 lines
3.7 KiB
CMake
83 lines
3.7 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
|
|
# unpack headers needed
|
|
set(SPC_DRV drv_header_v402b6844.zip)
|
|
set(SPC_HEADERS
|
|
include/spcerr.h
|
|
include/regs.h
|
|
include/dlltyp.h
|
|
include/spcioctl.inc)
|
|
|
|
add_custom_command(OUTPUT ${SPC_HEADERS}
|
|
COMMAND unzip -o -q -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
COMMENT "Unpacking SPC headers"
|
|
VERBATIM)
|
|
|
|
# Kernelmodule is build from NDA source code.
|
|
# just go to the current directory and tar xfz drvsrc_all_V*.tgz
|
|
# this will usually create a "linux" folder
|
|
# the actual kernel source file is in the src_all/micx_drv subfolder.
|
|
# If the "linux" folder exists the driver will be build.
|
|
# Alternatively you can set the SPC_SOURCE environment variable to the micx_drv folder
|
|
|
|
message("\nIf you have signed the NDA from Spectrum and got a kernel driver tarball (i.e. drvsrc_all_V*.tgz), put it in:\n\n\t" ${CMAKE_CURRENT_SOURCE_DIR} "\n\nto get a kernel module built\n")
|
|
file(GLOB MILIST "drvsrc_all_V*.tgz" )
|
|
# sort and select last (alphabetic order) tarball driver
|
|
list(SORT MILIST)
|
|
list(GET MILIST -1 MITGZ )
|
|
#message(STATUS ${MITGZ})
|
|
|
|
if(EXISTS ${MITGZ})
|
|
message(STATUS "Using spectrum driver source tarball: " ${MITGZ})
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv
|
|
COMMAND tar xfvz ${MITGZ}
|
|
COMMAND cp -v ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv/makefile.kernel26 ${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv/Makefile
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
COMMENT "Unpacking Spectrum driver tarball"
|
|
VERBATIM)
|
|
set(SPC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv")
|
|
add_custom_target(spc_smp ALL DEPENDS linux/src_all/micx_drv)
|
|
elseif(DEFINED ENV{SPC_SOURCE})
|
|
message(STATUS "SPC_SOURCE environment variable set:" $ENV{SPC_SOURCE})
|
|
set(SPC_SRC $ENV{SPC_SOURCE})
|
|
|
|
else()
|
|
set(SPC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv")
|
|
message(WARNING "Spectrum driver source path not defined in envirnoment variable SPC_SOURCE, using default:" ${SPC_SRC})
|
|
endif()
|
|
|
|
|
|
set(DRIVER_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
file(GLOB KERNEL_VERSIONS_DIR RELATIVE "/lib/modules" "/lib/modules/*/build")
|
|
foreach(KERNEL_DIR ${KERNEL_VERSIONS_DIR})
|
|
string(REPLACE "/build" "" KERNEL_VERSION ${KERNEL_DIR})
|
|
message(STATUS "Compiling spc_smp.ko for kernel: " ${KERNEL_VERSION})
|
|
set(DRIVER_FILE ${KERNEL_VERSION}/spc_smp.ko )
|
|
set(KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
|
|
-C "/lib/modules/${KERNEL_DIR}"
|
|
M=${SPC_SRC} modules)
|
|
|
|
add_custom_command(OUTPUT ${DRIVER_FILE}
|
|
COMMAND ls -lr .
|
|
COMMAND ${KBUILD_CMD}
|
|
COMMAND mkdir -p ${DRIVER_DIRECTORY}/${KERNEL_VERSION}
|
|
COMMAND cp -fv ${SPC_SRC}/spc_smp.ko ${DRIVER_DIRECTORY}/${KERNEL_VERSION}/spc_smp.ko
|
|
COMMENT "Building spc_smp.ko for kernel version: " ${KERNEL_VERSION}
|
|
WORKING_DIRECTORY ${SPC_SRC}
|
|
VERBATIM)
|
|
if(EXISTS ${SPC_SRC})
|
|
add_custom_target (micx_drv_${KERNEL_VERSION} ALL DEPENDS ${DRIVER_FILE} )
|
|
install(FILES ${DRIVER_FILE} DESTINATION /lib/modules/${KERNEL_VERSION}/kernel/damaris)
|
|
else()
|
|
message(WARNING "Spectrum MI40xx kernel driver directory not found\n " ${SPC_SRC} "\nunpack and configure it (i.e. set SPC_SOURCE variable)")
|
|
endif()
|
|
endforeach(KERNEL_DIR)
|
|
add_library(Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${SPC_HEADERS})
|
|
|
|
add_executable(hw_test_ext hw_test_extclock.cpp GatedData.cpp ${SPC_HEADERS})
|
|
#target_sources(hw_test_ext PRIVATE ${SPC_HEADERS})
|
|
|
|
add_executable(hw_test_int hw_test_intclock.cpp GatedData.cpp ${SPC_HEADERS})
|
|
#target_include_directories(hw_test_int ${SPC_HEADERS})
|