基于RK3399的Linux驱动开发 -- 用cmake创建kernel浏览工程

在kernel工程目录中创建一个cmake工程,用这个CMakeLists.txt替换原来的CMakeLists.txt即可在IDE中浏览kernel源代码,使用clion去浏览的时候不要太爽。

cmake_minimum_required(VERSION 3.14)
project(clion C)

set(CMAKE_C_STANDARD 90)

set(KERNEL_ROOT ${CMAKE_CURRENT_LIST_DIR}/..)

add_definitions(
        -D__KERNEL__
        -D__LINUX_ARM_ARCH__=7
)

include_directories(
        ${KERNEL_ROOT}/arch/arm/include
        ${KERNEL_ROOT}/arch/arm/include/generated

        ${KERNEL_ROOT}/include
)

file(GLOB SRCS
		# base
        ${KERNEL_ROOT}/drivers/base/*.c

        # mmc
        ${KERNEL_ROOT}/drivers/mmc/card/*.c
        ${KERNEL_ROOT}/drivers/mmc/core/*.c
        ${KERNEL_ROOT}/drivers/mmc/host/dw_mmc-pltfm.c
        ${KERNEL_ROOT}/drivers/mmc/host/dw_mmc-rockchip.c
        ${KERNEL_ROOT}/drivers/mmc/host/dw_mmc.c

        # i2c
        ${KERNEL_ROOT}/drivers/i2c/algos/*.c
        ${KERNEL_ROOT}/drivers/i2c/algos/*.c
        ${KERNEL_ROOT}/drivers/i2c/busses/i2c-rk3x.c
        ${KERNEL_ROOT}/drivers/i2c/busses/i2c-rk3x.c
        ${KERNEL_ROOT}/drivers/i2c/i2c-core.c
        ${KERNEL_ROOT}/drivers/i2c/i2c-dev.c

)

add_executable(clion main.c ${SRCS})
target_compile_options(clion PRIVATE -include ${KERNEL_ROOT}/include/linux/kconfig.h)

你可能感兴趣的:(Linux驱动开发)