2017-01-19 21:27:35 +00:00
cmake_minimum_required ( VERSION 3.0 )
2017-01-20 09:58:42 +00:00
# unpack headers needed
2017-01-26 16:56:17 +00:00
set ( SPC_DRV drv_header_v402b6844.zip )
2017-01-19 21:27:35 +00:00
set ( SPC_HEADERS
i n c l u d e / s p c e r r . h
i n c l u d e / r e g s . h
i n c l u d e / d l l t y p . h
i n c l u d e / s p c i o c t l . i n c )
add_custom_command ( OUTPUT ${ SPC_HEADERS }
2017-01-20 09:58:42 +00:00
C O M M A N D u n z i p - o - q - u $ { S P C _ D R V } " * . h " " * . t x t " " * . i n c " - d i n c l u d e /
2017-01-19 21:27:35 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
C O M M E N T " U n p a c k i n g S P C h e a d e r s "
V E R B A T I M )
2017-01-25 15:46:32 +00:00
# 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
2017-03-09 21:30:10 +00:00
# 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
2017-01-25 15:46:32 +00:00
2018-03-26 13:21:11 +00:00
file ( GLOB MILIST "drvsrc_all_V*.tgz" )
# sort and select last (alphabetic order) tarball driver
2018-04-03 12:37:21 +00:00
list ( SORT MILIST )
2018-04-03 13:14:42 +00:00
if ( MILIST )
list ( GET MILIST -1 MITGZ )
else ( )
set ( MITGZ "non-existing-file" )
endif ( )
2018-04-03 12:37:21 +00:00
#message(STATUS ${MITGZ})
2018-03-26 13:21:11 +00:00
if ( EXISTS ${ MITGZ } )
message ( STATUS "Using spectrum driver source tarball: " ${ MITGZ } )
add_custom_command ( OUTPUT ${ CMAKE_CURRENT_SOURCE_DIR } /linux/src_all/micx_drv
C O M M A N D t a r x f v z $ { M I T G Z }
2018-04-03 12:37:21 +00:00
C O M M A N D c p - v $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i n u x / s r c _ a l l / m i c x _ d r v / m a k e f i l e . k e r n e l 2 6 $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i n u x / s r c _ a l l / m i c x _ d r v / M a k e f i l e
2019-05-29 06:39:39 +00:00
C O M M A N D s e d - i " s / W n o - d e p r e c a t e d - d e c l a r a t i o n s / w / " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i n u x / s r c _ a l l / m i c x _ d r v / M a k e f i l e
2019-05-29 16:23:46 +00:00
# fails on jessie
C O M M A N D s e d - i " s / - W n o - e r r o r = d a t e - t i m e / / g " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i n u x / s r c _ a l l / m i c x _ d r v / M a k e f i l e
2018-04-03 13:14:42 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2018-03-26 13:21:11 +00:00
C O M M E N T " U n p a c k i n g S p e c t r u m d r i v e r t a r b a l l "
2018-04-03 13:14:42 +00:00
V E R B A T I M )
2018-03-26 13:21:11 +00:00
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} )
2018-12-12 08:45:28 +00:00
message ( STATUS "SPC_SOURCE environment variable set: " $ENV{ SPC_SOURCE } )
2017-01-26 16:56:17 +00:00
set ( SPC_SRC $ENV{ SPC_SOURCE } )
else ( )
2018-03-26 13:21:11 +00:00
set ( SPC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/linux/src_all/micx_drv" )
2019-05-29 08:03:37 +00:00
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" )
2018-12-12 08:45:28 +00:00
message ( WARNING "Spectrum driver source path not defined in envirnoment variable SPC_SOURCE,\nusing default: " ${ SPC_SRC } )
2017-01-26 16:56:17 +00:00
endif ( )
2017-01-25 15:46:32 +00:00
2018-03-26 13:21:11 +00:00
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 " / l i b / m o d u l e s / $ { K E R N E L _ D I R } "
M = $ { S P C _ S R C } m o d u l e s )
add_custom_command ( OUTPUT ${ DRIVER_FILE }
C O M M A N D $ { K B U I L D _ C M D }
C O M M A N D m k d i r - p $ { D R I V E R _ D I R E C T O R Y } / $ { K E R N E L _ V E R S I O N }
2018-04-03 12:37:21 +00:00
C O M M A N D c p - f v $ { S P C _ S R C } / s p c _ s m p . k o $ { D R I V E R _ D I R E C T O R Y } / $ { K E R N E L _ V E R S I O N } / s p c _ s m p . k o
2018-03-26 13:21:11 +00:00
C O M M E N T " B u i l d i n g s p c _ s m p . k o f o r k e r n e l v e r s i o n : " $ { K E R N E L _ V E R S I O N }
W O R K I N G _ D I R E C T O R Y $ { S P C _ S R C }
V E R B A T I M )
2019-05-29 16:04:32 +00:00
add_custom_target ( micx_drv_ ${ KERNEL_VERSION } ALL DEPENDS ${ DRIVER_FILE } )
install ( FILES ${ DRIVER_FILE } DESTINATION /lib/modules/ ${ KERNEL_VERSION } /kernel/damaris )
2018-03-26 13:21:11 +00:00
endforeach ( KERNEL_DIR )
2017-01-19 21:27:35 +00:00
add_library ( Spectrum_MI40xxSeries STATIC Spectrum-MI40xxSeries.cpp GatedData.cpp ${ SPC_HEADERS } )
2017-03-09 21:30:10 +00:00
add_executable ( hw_test_ext hw_test_extclock.cpp GatedData.cpp ${ SPC_HEADERS } )
2017-02-06 21:31:58 +00:00
#target_sources(hw_test_ext PRIVATE ${SPC_HEADERS})
2017-03-09 21:30:10 +00:00
add_executable ( hw_test_int hw_test_intclock.cpp GatedData.cpp ${ SPC_HEADERS } )
2017-02-06 21:31:58 +00:00
#target_include_directories(hw_test_int ${SPC_HEADERS})