Skip to content

Commit

Permalink
SMP linux/gnu: add cmake for sample
Browse files Browse the repository at this point in the history
This allows to build SMP variant of `linux/gnu` port, and optionally
with `sample_threadx`.

Signed-off-by: Yanfeng Liu <[email protected]>
  • Loading branch information
yf13 committed Sep 21, 2024
1 parent 50a7596 commit 599709d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ports_smp/linux/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_low_level_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_preempt.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_protect.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_current_state_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_time_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_current_thread_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_unprotect.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_initialize_wait.c

# {{END_TARGET_SOURCES}}
)

target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)

target_compile_definitions(${PROJECT_NAME} PUBLIC "-D_GNU_SOURCE -DTX_LINUX_DEBUG_ENABLE")

if(DEFINED THREADX_SAMPLE)
add_subdirectory(example_build)
endif()
15 changes: 15 additions & 0 deletions ports_smp/linux/gnu/example_build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build sample_threadx program

project(sample_threadx)
set(SRCS sample_threadx.c)

add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME} PRIVATE ${SRCS})
set_target_properties(
${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/../../../../)
target_include_directories(
${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../inc
${CMAKE_CURRENT_LIST_DIR}/../../../../common_smp/inc)

target_link_libraries(${PROJECT_NAME} PRIVATE threadx)

0 comments on commit 599709d

Please sign in to comment.