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

[chg] Splitted toki-libc-printf into -headers and -port

Moved _putchar method to port part
parent e22cc977
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
toki-libc-printf-headers
#
VERSION 0.1
LANGUAGES C ASM
)
add_library(
toki-libc-printf-headers
#
INTERFACE
)
target_include_directories(
toki-libc-printf-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}
)
# 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()
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-printf-headers-targets.cmake)
check_required_components(toki-libc-printf-headers)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
toki-libc-printf-port
#
VERSION 0.1
LANGUAGES C ASM
)
find_package(
toki-libc-printf-headers 0.1
REQUIRED
)
find_package(
xil-headers 7.0
REQUIRED
)
add_library(
toki-libc-printf-port
#
STATIC
"" # The sources are added in the respective sub-folders
)
target_link_libraries(
toki-libc-printf-port
PRIVATE
toki-libc-printf-headers
xil-headers
)
add_subdirectory(src)
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()
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
toki-libc-printf-port
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/putchar.c"
)
#include <stdio.h>
#include "xil/xparameters.h"
#include "xil/drivers/xuartps_hw.h"
void _putchar(char character) {
XUartPs_SendByte(STDOUT_BASEADDRESS, character);
}
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(xil-headers 7.0)
find_dependency(toki-libc-printf-headers 0.1)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-printf-port-targets.cmake)
check_required_components(toki-libc-printf-port)
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