[CMake] cross compiling with sdcc

Torsten at Robitzki.de Torsten at Robitzki.de
Fri May 29 05:14:06 EDT 2015


Hello,
I was looking for some resources on how to configure cmake to use the small device c compiler (sdcc). I tried a little bit and found that cmake assumed that the object file extension would be .obj. But sdcc uses .rel for object files. I’ve searched a lot in the web and the cmake sources, tried to figure out, how the compiler detection mechanism works.

I saw that there is a file Platform/Generic-SDCC-C.cmake, while searching for a way to force cmake to use this file, I found a makro CMAKE_FORCE_C_COMPILER that let me override the compiler detection. 

So now I have a working solution and wonder if that solution is one „correct“ solution. „correct“ in terms of supported and intended by the developers.

    cmake_minimum_required(VERSION 3.2)
    include (CMakeForceCompiler)
    set(CMAKE_SYSTEM_NAME Generic)
    CMAKE_FORCE_C_COMPILER(sdcc SDCC)

    project(test C)

Does this looks reasonable? Thank you very much for your time!

Kind regards,

Torsten



More information about the CMake mailing list