110 lines
2.7 KiB
CMake
110 lines
2.7 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}
|
|
OR NOT DEFINED ENV{VXSDK_BUILD_CFLAGS}
|
|
OR NOT DEFINED ENV{VXSDK_PREFIX_BUILD}
|
|
OR NOT DEFINED ENV{VXSDK_PREFIX_INSTALL})
|
|
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})
|
|
set(VXSDK_PREFIX_BUILD $ENV{VXSDK_PREFIX_BUILD})
|
|
set(VXSDK_PREFIX_INSTALL $ENV{VXSDK_PREFIX_INSTALL})
|
|
set(VXSDK_BUILD_CFLAGS $ENV{VXSDK_BUILD_CFLAGS})
|
|
|
|
|
|
#---
|
|
# handle configuration-specific information
|
|
#---
|
|
|
|
set(VXKERNEL_CONF ${VXSDK_PREFIX_BUILD}/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 kernel/src/modules/${mod})
|
|
endforeach()
|
|
|
|
foreach(drv ${VXKERNEL_ENABLE_DRIVERS})
|
|
list(APPEND VXKERNEL_DIR_TARGETS kernel/src/drivers/${drv})
|
|
endforeach()
|
|
|
|
set(board_prefix 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()
|
|
|
|
file(GLOB dir_src kernel/src/*.c kernel/src/*.S kernel/src/*.s)
|
|
list(APPEND VXKERNEL_SRC_TARGETS ${dir_src})
|
|
|
|
list(APPEND VXKERNEL_INC_TARGETS 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 ${VXSDK_BUILD_CFLAGS})
|
|
add_library(vxkernel ${VXKERNEL_SRC_TARGETS})
|
|
|
|
#---
|
|
# Install-specific declaration
|
|
#---
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${VXSDK_PREFIX_INSTALL})
|
|
install(TARGETS vxkernel DESTINATION "lib")
|
|
install(DIRECTORY kernel/include/ DESTINATION "include")
|
|
install(FILES ${VXKERNEL_INSTALL_EXTRA_FILES} DESTINATION "lib")
|