102 lines
2.4 KiB
CMake
102 lines
2.4 KiB
CMake
|
cmake_minimum_required(VERSION 3.15)
|
||
|
|
||
|
|
||
|
#---
|
||
|
# handle vxSDK-specific
|
||
|
#---
|
||
|
|
||
|
if(NOT DEFINED ENV{VXSDK_PKG_NAME} OR NOT DEFINED ENV{VXSDK_PKG_VERSION})
|
||
|
message(FATAL_ERROR "You should use the vxSDK to build this project")
|
||
|
endif()
|
||
|
|
||
|
set(VXSDK_PKG_NAME $ENV{VXSDK_PKG_NAME})
|
||
|
set(VXSDK_PKG_VERSION $ENV{VXSDK_PKG_VERSION})
|
||
|
|
||
|
|
||
|
#---
|
||
|
# handle configuration-specific information
|
||
|
#---
|
||
|
|
||
|
set(VXKERNEL_CONF ${CMAKE_CURRENT_SOURCE_DIR}/.vxsdk/vxkernel_config.cmake)
|
||
|
|
||
|
if(NOT EXISTS ${VXKERNEL_CONF})
|
||
|
message(FATAL_ERROR "You should performs project configuration")
|
||
|
endif()
|
||
|
|
||
|
include(${VXKERNEL_CONF})
|
||
|
|
||
|
if(NOT DEFINED VXKERNEL_ENABLE_MODULES)
|
||
|
message(FATAL_ERROR "Missing module declaration")
|
||
|
elseif(NOT DEFINED VXKERNEL_ENABLE_DRIVERS)
|
||
|
message(FATAL_ERROR "Missing driver declaration")
|
||
|
endif()
|
||
|
|
||
|
|
||
|
#---
|
||
|
# handle project-specific information
|
||
|
#---
|
||
|
|
||
|
project(${VXSDK_PKG_NAME} VERSION ${VXSDK_PKG_VERSION} LANGUAGES C ASM)
|
||
|
|
||
|
|
||
|
#---
|
||
|
# Handle source listing
|
||
|
#---
|
||
|
|
||
|
set(VXKERNEL_SRC_TARGETS "")
|
||
|
set(VXKERNEL_INC_TARGETS "")
|
||
|
set(VXKERNEL_DIR_TARGETS "")
|
||
|
|
||
|
foreach(mod ${VXKERNEL_ENABLE_MODULES})
|
||
|
list(
|
||
|
APPEND
|
||
|
VXKERNEL_DIR_TARGETS
|
||
|
${CMAKE_CURRENT_SOURCE_DIR}/kernel/src/modules/${mod}
|
||
|
)
|
||
|
endforeach()
|
||
|
|
||
|
foreach(drv ${VXKERNEL_ENABLE_DRIVERS})
|
||
|
list(
|
||
|
APPEND
|
||
|
VXKERNEL_DIR_TARGETS
|
||
|
${CMAKE_CURRENT_SOURCE_DIR}/kernel/src/drivers/${drv}
|
||
|
)
|
||
|
endforeach()
|
||
|
|
||
|
set(board_prefix ${CMAKE_CURRENT_SOURCE_DIR}/boards/${VXKERNEL_ENABLE_BOARD})
|
||
|
if(EXISTS ${board_prefix}/src)
|
||
|
list(APPEND VXKERNEL_DIR_TARGETS ${board_prefix}/src)
|
||
|
endif()
|
||
|
|
||
|
foreach(dir ${VXKERNEL_DIR_TARGETS})
|
||
|
file(GLOB_RECURSE dir_src ${dir}/*.c ${dir}/*.S ${dir}/*.s)
|
||
|
list(APPEND VXKERNEL_SRC_TARGETS ${dir_src})
|
||
|
endforeach()
|
||
|
|
||
|
set(dir ${CMAKE_CURRENT_SOURCE_DIR}/kernel/src)
|
||
|
file(GLOB dir_src ${dir}/*.c ${dir}/*.S ${dir}/*.s)
|
||
|
list(APPEND VXKERNEL_SRC_TARGETS ${dir_src})
|
||
|
|
||
|
list(APPEND VXKERNEL_INC_TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/kernel/include)
|
||
|
if(EXISTS ${board_prefix}/include)
|
||
|
list(APPEND VXKERNEL_INC_TARGETS ${board_prefix}/include)
|
||
|
endif()
|
||
|
|
||
|
if(DEFINED VXKERNEL_CMAKE_DEBUG)
|
||
|
message(
|
||
|
FATAL_ERROR
|
||
|
"dir list = ${VXKERNEL_DIR_TARGETS}\n"
|
||
|
"src list = ${VXKERNEL_SRC_TARGETS}\n"
|
||
|
"inc list = ${VXKERNEL_INC_TARGETS}\n"
|
||
|
)
|
||
|
endif()
|
||
|
|
||
|
|
||
|
#---
|
||
|
# Compile-specific declaration
|
||
|
#---
|
||
|
|
||
|
include_directories(${VXKERNEL_INC_TARGETS})
|
||
|
add_compile_options(-Wall -Wextra ${VXKERNEL_EXTRA_CFLAGS})
|
||
|
add_library(vxkernel ${VXKERNEL_SRC_TARGETS})
|