CONTEXT
I have an embedded project that includes different target platforms (eg. ARM using Arm GNU Toolchain, Microchip using MPLAB XC32, Windows using MSVC). Each has it's own "port" subdirectory containing the platform-dependant code. Additionally I have different third-party source files (eg. SDK with auto-generated code, CANOpen stack with auto-generated code, ...).
PROBLEM
I need to compile specific subdirectories with different compiler args for example:
- warnings
unreadable output due to third-party sources and unable to usewerror - optimization levels
optimize already tested or not interested modules on debugging/inspection, due to size constraints (currently done using gcc attributes) - defines
enabling detailed logging or other debugging options for the inspecting module
APPROACHES
- The solution to think of was to generate the object files in the subdirectories and link everything together in the root build_target. I would probably be able to get this done by manually compiling the subdirectories using
run_command,custom_targetorcompiler.runbut that seems to be a lot of work and I would probably need to add all the different options and args manually. - I also tried using
declare_dependencybut thecompiler_argsare basically just inherited by thebuild_target. - My third idea is using
static_librarywithb_lundef=true(or/FORCE:UNRESOLVEDrespectively), but I am not entirely sure how to set that up to not break debugging or memory sections (eg. initcalls, parameterizable constants, ...).