Commit fcf40e8b authored by Oliver Horst's avatar Oliver Horst
Browse files

[chg] Added a CMake based build system and adapted sources to the new structure

parent 1e5d7227
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
find_package(
freertos-config 0.1
REQUIRED
)
get_target_property(
CONFIG_DEFINES
freertos-config
INTERFACE_COMPILE_DEFINITIONS
)
foreach(DEFINE ${CONFIG_DEFINES})
string(REGEX MATCH "^(.+)=(.+)$" TEMP "${DEFINE}")
set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2} CACHE STRING "Configuration option set in the target configuration.")
endforeach()
message(STATUS "Building FreeRTOS Portable with\n\tcompiler = ${FREERTOS_COMPILER}\n\tplatform = ${FREERTOS_PLATFORM}")
add_subdirectory(${FREERTOS_COMPILER})
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
option(WITH_HEADERS "Enable the installation of header files" ON)
project(
freertos-portable
#
VERSION 0.1
LANGUAGES C ASM
)
find_package(
freertos-headers 10.0.0
REQUIRED
)
add_library(
freertos-portable
#
STATIC
"" # The sources are added in the respective sub-folders
)
target_link_libraries(
freertos-portable
#
PRIVATE freertos-headers
)
target_include_directories(
freertos-portable
#
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>
)
add_subdirectory(src)
if (WITH_HEADERS)
add_subdirectory(include)
endif()
if (ENABLE_INSTALL)
# Configure and install the following files:
# - ${PROJECT_NAME}-config.cmake,
# - ${PROJECT_NAME}-config-version.cmake,
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
# ${PROJECT_NAME}-config.cmake
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
# ${PROJECT_NAME}-config-config-version.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion
)
# Install exported CMake target files
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${ConfigPackageLocation}
EXPORT_LINK_INTERFACE_LIBRARIES
)
# Install package/module configuration files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${ConfigPackageLocation}
)
endif()
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(freertos-headers)
find_dependency(freertos-config)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/freertos-targets.cmake)
check_required_components(freertos-plus)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
freertos-portable-headers
#
VERSION 0.1
LANGUAGES C ASM
)
add_library(
freertos-portable-headers
#
INTERFACE
)
target_include_directories(
freertos-portable-headers
#
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
INTERFACE $<INSTALL_INTERFACE:include>
)
if (ENABLE_INSTALL)
# Configure and install the following files:
# - ${PROJECT_NAME}-config.cmake,
# - ${PROJECT_NAME}-config-version.cmake,
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
# ${PROJECT_NAME}-config.cmake
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
# ${PROJECT_NAME}-config-config-version.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion
)
# Install exported CMake target files
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${ConfigPackageLocation}
EXPORT_LINK_INTERFACE_LIBRARIES
)
# Install package/module configuration files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${ConfigPackageLocation}
)
# If desired install all header files of the current project
get_target_property(PROJECT_INCLUDE_DIRECTORIES ${PROJECT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
foreach(DIR ${PROJECT_INCLUDE_DIRECTORIES})
string(REGEX MATCH "^.<BUILD_INTERFACE:(.*)>$" EXTRACTED_DIR ${DIR})
if (CMAKE_MATCH_1)
set(EXTRACTED_DIR "${CMAKE_MATCH_1}")
file(
GLOB_RECURSE
#
HEADER_FILES
#
FOLLOW_SYMLINKS
LIST_DIRECTORIES FALSE
RELATIVE "${EXTRACTED_DIR}"
#
"${EXTRACTED_DIR}/*.h"
"${EXTRACTED_DIR}/*.hpp"
)
foreach(FILE ${HEADER_FILES})
get_filename_component(INSTALL_PATH ${FILE} DIRECTORY)
install(
FILES ${EXTRACTED_DIR}/${FILE}
DESTINATION include/${INSTALL_PATH}
)
endforeach()
endif()
endforeach()
endif()
// SPDX-License-Identifier: GPL-2.0
#ifndef STM_TRACE_H
#define STM_TRACE_H
......@@ -94,11 +92,11 @@ extern struct stm_drvdata drvdata;
/**
* \brief Enable timestamping. ENABLE THIS BEFORE turning on stm tracing.
*/
void timestamp_enable();
void timestamp_enable();
/**
* \brief Enable STM tracing.
*/
int stm_enable();
#endif /* STM_TRACE_H */
\ No newline at end of file
#endif /* STM_TRACE_H */
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/freertos-plus-headers-targets.cmake)
check_required_components(freertos-plus-headers)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
add_subdirectory(freertos)
add_subdirectory(freertos+)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
add_subdirectory(hal)
add_subdirectory(memguard)
add_subdirectory(perfmon)
add_subdirectory(trace)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/cpu.c"
......
#include "freertos/FreeRTOS.h"
#include "freertos/hal/cpu.h"
#include "freertos+/hal/cpu.h"
#include "xil/xpseudo_asm.h"
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/uart.c"
......
......@@ -9,13 +9,14 @@
/******************************************************************************/
/*** Includes ***/
/******************************************************************************/
#include "freertos/hal/drivers/can.h"
#include "freertos/FreeRTOS.h"
#include "freertos/core/queue.h"
#include "freertos/core/task.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "freertos/portmacro.h"
#include "freertos+/hal/drivers/can.h"
#include "xil/xparameters.h"
#include "xil/drivers/xcanps.h"
#include "xil/drivers/xscugic.h"
......
......@@ -7,7 +7,7 @@
/*** Includes ***/
/******************************************************************************/
#include "freertos/hal/drivers/uart.h"
#include "freertos+/hal/drivers/uart.h"
#include "xil/xparameters.h"
#include "xil/drivers/xuartps.h"
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/memguard_arch.c"
......
......@@ -7,9 +7,9 @@
#include "xil/drivers/xttcps.h"
#include "xil/drivers/xscugic.h"
#include "freertos/hal/cpu.h"
#include "freertos/extra/perfmon.h"
#include "freertos/extra/memguard.h"
#include "freertos+/hal/cpu.h"
#include "freertos+/perfmon.h"
#include "freertos+/memguard.h"
/* Base address of the on-chip memory where we store the variables shared
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/perfmon_arch.c"
......
......@@ -7,7 +7,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/extra/perfmon.h"
#include "freertos+/perfmon.h"
#include "xil/xpseudo_asm.h"
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/coresight.c"
"${CMAKE_CURRENT_LIST_DIR}/stm_trace.c"
)
// SPDX-License-Identifier: GPL-2.0
/*
* This file is based on coresight-stm.c from the linux kernel source.
*
......@@ -19,8 +18,11 @@
*/
#include "freertos/FreeRTOS.h"
#include "freertos/core/task.h"
#include "freertos+/coresight/coresight.h"
#if ENABLE_stm_trace == 1
#include "freertos/task.h"
#include "freertos+/trace/stm_trace.h"
#include "xil/xil_io.h"
#include "xil/csparameters.h"
......@@ -68,8 +70,8 @@
#define CORESIGHT_UNLOCK 0xc5acce55
struct stm_drvdata drvdata = {
.base = CS_STM_BASE,
.axi = CS_STM_AXI_BASE,
.base = (void *)( CS_STM_BASE ),
.axi = (struct stm_axi *)( CS_STM_AXI_BASE ),
.stmspscr = CS_STMSPSCR,
.stmsper = CS_STMSPER,
......@@ -194,3 +196,5 @@ void timestamp_enable()
*ts_enable = 0x1 | (configTS_GEN_DEBUG_HALT << 1);
}
#endif /* ENABLE_stm_trace == 1 */
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
freertos
freertos-portable
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/port.c"
......@@ -9,6 +9,3 @@ target_sources(
"${CMAKE_CURRENT_LIST_DIR}/portZynqUltrascale.c"
"${CMAKE_CURRENT_LIST_DIR}/port_asm_vectors.S"
)
add_subdirectory(hal)
add_subdirectory(drivers)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment