Skip to content

cmake: fixed THREADX_ARCH undefined when building as standalone library#540

Merged
fdesbiens merged 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/cmake-threadx-arch-undefined
May 29, 2026
Merged

cmake: fixed THREADX_ARCH undefined when building as standalone library#540
fdesbiens merged 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/cmake-threadx-arch-undefined

Conversation

@fdesbiens

@fdesbiens fdesbiens commented May 29, 2026

Copy link
Copy Markdown
Contributor

CMake loads the toolchain file during the first project() call. Variables set in the toolchain (THREADX_ARCH, THREADX_TOOLCHAIN) were therefore not visible before project() was invoked. Commit 2c16114 moved project() after those checks to conditionally select LANGUAGES and CMAKE_TRY_COMPILE_TARGET_TYPE for Windows, which broke standalone builds that rely on the toolchain to supply THREADX_ARCH.

Fixed by calling project(threadx LANGUAGES C) first so the toolchain is sourced, then checking THREADX_ARCH, then conditionally enabling ASM via enable_language(ASM) for non-Windows ports. The CMAKE_TRY_COMPILE_TARGET_TYPE override was removed from CMakeLists.txt because every toolchain file in cmake/ already sets it to STATIC_LIBRARY where needed.

PR checklist

  • Updated function header with a short description and version number
  • Added test case for bug fix or new feature
  • Validated on real hardware

CMake loads the toolchain file during the first project() call.
Variables set in the toolchain (THREADX_ARCH, THREADX_TOOLCHAIN) were
therefore not visible before project() was invoked.  Commit 2c16114
moved project() after those checks to conditionally select LANGUAGES and
CMAKE_TRY_COMPILE_TARGET_TYPE for Windows, which broke standalone builds
that rely on the toolchain to supply THREADX_ARCH.

Fixed by calling project(threadx LANGUAGES C) first so the toolchain is
sourced, then checking THREADX_ARCH, then conditionally enabling ASM via
enable_language(ASM) for non-Windows ports.  The CMAKE_TRY_COMPILE_TARGET_TYPE
override was removed from CMakeLists.txt because every toolchain file in
cmake/ already sets it to STATIC_LIBRARY where needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@fdesbiens fdesbiens merged commit 518127b into eclipse-threadx:dev May 29, 2026
1 check passed
@fdesbiens fdesbiens deleted the fix/cmake-threadx-arch-undefined branch May 29, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant