66 lines
1.4 KiB
CMake
66 lines
1.4 KiB
CMake
|
cmake_minimum_required(VERSION 3.12)
|
||
|
project(hello-world C)
|
||
|
|
||
|
# Set default board to iss if not specified
|
||
|
if(NOT DEFINED BOARD)
|
||
|
set(BOARD "iss" CACHE STRING "Target board")
|
||
|
endif()
|
||
|
|
||
|
#set(BSP_BASE "${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp")
|
||
|
|
||
|
|
||
|
|
||
|
# Source files
|
||
|
set(SOURCES
|
||
|
hello.c
|
||
|
)
|
||
|
|
||
|
message(STATUS "Building for board: ${BOARD}")
|
||
|
message(STATUS "liu:${PROJECT_NAME} ")
|
||
|
message(STATUS "Using board-specific files from: ${BSP_BASE}/env/${BOARD}")
|
||
|
|
||
|
# Create executable with all objects
|
||
|
add_executable(${PROJECT_NAME}
|
||
|
${SOURCES}
|
||
|
${BSP_OBJECTS}
|
||
|
|
||
|
|
||
|
)
|
||
|
|
||
|
# Link with board library
|
||
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||
|
${LIBWRAP_OBJECTS}
|
||
|
${ENV_OBJECTS}
|
||
|
#$<TARGET_OBJECTS:env_entry>
|
||
|
#$<TARGET_OBJECTS:env_start>
|
||
|
)
|
||
|
|
||
|
# Include directories
|
||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||
|
${BSP_BASE}/include
|
||
|
${BSP_BASE}/drivers
|
||
|
${BSP_BASE}/env
|
||
|
${BSP_BASE}/env/${BOARD}
|
||
|
${BSP_BASE}/libwrap
|
||
|
)
|
||
|
|
||
|
# Add compile definitions
|
||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||
|
BOARD_${BOARD}
|
||
|
)
|
||
|
|
||
|
# link global_compile_options to this target
|
||
|
target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||
|
|
||
|
# Set linker options
|
||
|
target_link_options(${PROJECT_NAME} PRIVATE
|
||
|
-T${BSP_BASE}/env/${BOARD}/link.ld
|
||
|
-nostartfiles
|
||
|
-Wl,--gc-sections
|
||
|
)
|
||
|
|
||
|
# Install target
|
||
|
install(TARGETS ${PROJECT_NAME}
|
||
|
RUNTIME DESTINATION bin
|
||
|
)
|