linux/gnu: add cmake for sample - #404
Conversation
d076032 to
4398acd
Compare
This allows to build `sample_threadx` together with `libthreadx.a`. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
4398acd to
17c656e
Compare
This allows one to build `sample_threadx` with `libthreadx.a` by adding `-DTHREADX_SAMPLE=1` to cmake command line. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This allows to build SMP variant `libthreadx.a` with cmake. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
599709d to
b70e00e
Compare
This allows to build SMP variant of `linux/gnu` port, and optionally with `sample_threadx`. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
b70e00e to
2f170bd
Compare
|
Thank you for this, and apologies that it sat for so long. The goal is right and it is still missing: the CMake build produces only the library, so trying ThreadX on Linux means using the Makefile instead. I have opened #622 to add it, derived from your two I am closing this one rather than rebasing it, and I would rather explain why than leave it looking like a rejection. Four of the six files here have since arrived on Two details from the superseded part are worth passing back, since they may be useful to you elsewhere. The SMP switch used
And the path scheme built One change was needed to your example files themselves: they read Both variants now build and run — the non-SMP demo prints its banner and counters, and the SMP one prints the SMP banner. Credit for the idea and the starting point is recorded in #622 and in its commit message. Thank you for the contribution, and for #403, which was merged. |
The CMake build produced libthreadx.a and nothing else, so trying ThreadX on
Linux meant using the Makefile beside the port instead. Build the demo the
Makefile builds, for the linux port and its SMP counterpart.
The target is behind an option that defaults off, so an ordinary build is
unchanged and still produces just the library. -DTHREADX_SAMPLE=ON adds it:
cmake -S . -B build -DTHREADX_ARCH=linux -DTHREADX_TOOLCHAIN=gnu \
-DTHREADX_SAMPLE=ON
cmake --build build --target sample_threadx
The include path uses TX_COMMON_DIR rather than naming common or common_smp,
since the top level already resolves which of the two applies.
Verified by building and running both variants. Non-SMP prints
**** ThreadX Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
and SMP prints the SMP banner, both with the demo's thread counters advancing. A
default configure with no THREADX_SAMPLE has no sample_threadx target and still
produces libthreadx.a, so nothing existing moves.
Derived from the two example_build files in #404 by Yanfeng Liu, which had the
same goal. That change also rewrote the top level's SMP selection, added
common_smp/CMakeLists.txt and added ports_smp/linux/gnu/CMakeLists.txt; all three
have since arrived on dev by other routes, so only the sample targets were still
missing. The include path needed adjusting because the original depended on
THREADX_SMP being a string suffix, which it no longer is.
Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
The CMake build produced libthreadx.a and nothing else, so trying ThreadX on
Linux meant using the Makefile beside the port instead. Build the demo the
Makefile builds, for the linux port and its SMP counterpart.
The target is behind an option that defaults off, so an ordinary build is
unchanged and still produces just the library. -DTHREADX_SAMPLE=ON adds it:
cmake -S . -B build -DTHREADX_ARCH=linux -DTHREADX_TOOLCHAIN=gnu \
-DTHREADX_SAMPLE=ON
cmake --build build --target sample_threadx
The include path uses TX_COMMON_DIR rather than naming common or common_smp,
since the top level already resolves which of the two applies.
Verified by building and running both variants. Non-SMP prints
**** ThreadX Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
and SMP prints the SMP banner, both with the demo's thread counters advancing. A
default configure with no THREADX_SAMPLE has no sample_threadx target and still
produces libthreadx.a, so nothing existing moves.
Derived from the two example_build files in eclipse-threadx#404 by Yanfeng Liu, which had the
same goal. That change also rewrote the top level's SMP selection, added
common_smp/CMakeLists.txt and added ports_smp/linux/gnu/CMakeLists.txt; all three
have since arrived on dev by other routes, so only the sample targets were still
missing. The include path needed adjusting because the original depended on
THREADX_SMP being a string suffix, which it no longer is.
Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
This adds CMake support for
linux/gnu/example_buildso that to have thesample_threadxtarget built after thelibthreadx.atarget, make it easier for people to try the sample on Linux.