I’m having quite some trouble finding a way to modify CMAKE_C_LINK_EXECUTABLE/CMAKE_CXX_LINK_EXECUTABLE for my embedded cross-compilation project. The compiler ID resolves correctly to “TI” and subsequencly TI-C.cmake and TI-CXX.cmake are loaded. However there is an issue with the order of arguments in those files with the newer version of the vendor toolchain. Specifically, some of the linker options need to come before the --run-linker command.
I’ve also tried by creating the file cmake/Platform/Generic-TI-C.cmake and modifying CMAKE_C_LINK_EXECUTABLE there (as suggested here). This was on the root of my project and I also added ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ to the front of CMAKE_MODULE_PATH but that didn’t yield results. It didn’t appear like the file was being loaded at all.
Per the compiler errors and warnings, some of the flags need to come before the --run_linker command. So, I’d like this rule variable to look a little different, something like this (with LINK_FLAGS before --run_linker:
My current approach is to define my own “Platform” (as linked above) so I can set this variable there, but I’m not having luck loading the platform’s .cmake file
I have found a fix to my problem. It was actually much easier than I was making it out to be. The variable CMAKE_<LANG>_LINK_EXECUTABLE does not need to be defined before calling project() as I was attempting to do by defining it as a Platform/ or in the toolchain file. It can actually be defined in the CMakeLists.txt file, after the call to project().
Defining this rule variable before the call to project() might be possible in a Platform/ file or some other way, but I had no luck with that approach.