Apply toolchain after SystemSpecific

I use toolchain for cc65 compiler:

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR 6502)
...
...
set(CMAKE_LINK_LIBRARY_FLAG "")

And use this like cmake -DCMAKE_TOOLCHAIN_FILE=cc65.cmake -Bbuild

In this case my CMAKE_LINK_LIBRARY_FLAG is “-l” because is was set in “Modules/CMakeGenericSystem.cmake” after my toolchain.

Is there some way to apply the toolchain AFTER the system one?

There have been similar questions about toolchain files. The developers have said that kind of setting doesn’t belong in the toolchain file. You can override the compiler and platform settings using CMAKE_USER_MAKE_RULES_OVERRIDE.

Refer to:
https://gitlab.kitware.com/cmake/cmake/merge_requests/1941#note_398139
https://gitlab.kitware.com/cmake/cmake/issues/17880#note_397841

1 Like