Search code examples
cmakemacrosstub

CMake Stub Macro


I am working in a project and have a subdirectory called AdcHandler. in this subdirectory, there is a CMakeList.txt file to include the file ADC.c.

CMakeList.txt:    
set(inFiles "${CMAKE_CURRENT_SOURCE_DIR}/ADC.c")
    cmt_pf_module_newConfig(AdcHandler)
    ...etc

The CMakeList.txt file has an invalid macro called "cmt_pf_module_newConfig".

The error "Unknown CMake command "cmt_pf_module_newConfig" pops up when building the software.

To resolve the error, I have to stub "cmt_pf_module_newConfig" it "empty" instead of deleting the line!

How can I stub it? I have to use a new file for the stubbing because there are a lot of subdirectories which has invalid macros! I have to stub the macro's because these macros are used in another project. So we will get month by month delivery for include the subdirectories. Therefore it dont make sense to solve the macro problem, because in our project we are using different macros.

Thanks.


Solution

  • If I understand your question correctly, then all you need to do is define the CMake command as empty:

    macro(cmt_pf_module_newConfig)
    endmacro()
    

    You're mentioning the offending macro is used in subdirectories, so just add the above definition into a CMakeList above all those subdirectories, before any of them is passed to add_subdirectory.

    Note that this will turn the command into a no-op. Whether the subdirectory CMakeList will still work as intended with this change depends on your project and what the command is supposed to do.