Fix CMake compilation error caused by deprecated linker flag variables #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users encountered a CMake compiler test failure when configuring STM32 projects in CLion. After setting up the toolchain and clicking "Confirm" (确认), the build would fail with the following error:
This prevented users from successfully building their STM32 projects, as shown in issue screenshots.
Root Cause
The
gcc-arm-none-eabi.cmaketoolchain file was using deprecated CMake variables for linker flags:CMAKE_C_LINK_FLAGS(deprecated, not recognized by modern CMake)CMAKE_CXX_LINK_FLAGS(deprecated, not recognized by modern CMake)These variables are no longer properly handled by CMake 3.28+, causing linker flags to be passed incorrectly during the compiler detection phase, which results in the linker receiving malformed arguments.
Solution
Updated the toolchain configuration to use the modern, standard CMake variable:
CMAKE_C_LINK_FLAGSwithCMAKE_EXE_LINKER_FLAGSCMAKE_CXX_LINK_FLAGSvariableTOOLCHAIN_LINK_LIBRARIESfor consistency with the workingstarm-clang.cmakeconfigurationThis aligns the GCC ARM toolchain with CMake best practices and matches the approach already used successfully in the Clang toolchain configuration in this repository.
Documentation
Added a comprehensive troubleshooting section (常见编译问题) to the README that:
Verification
The fix can be verified by CMake documentation:
References
Fixes #[issue_number]
Original prompt
Fixes #8
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.