colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

--cmake-args overwrites default values #29

Closed richiware closed 5 years ago

richiware commented 5 years ago

I have a default.yaml where I specify some default cmake options to be passed to my cmake projects.

{
    "build":
    {
        "cmake-args": ["-G", "Ninja", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", "-DCMAKE_CXX_FLAGS=\"-fdebug-prefix-map=${CMAKE_BINARY_DIR}=\""]
    }
}

Also I add some default cmake options in some project using colcon.meta.

{
    "names":
    {
        "fastrtps" :
        {
            "cmake-args": ["-DEPROSIMA_BUILD=ON"]
        }
    }
}

If I use colcon to build using a command line like colcon build --paths ../.. --metas ../.., the cmake projects are configured with the default cmake options. But if I add a cmake option using --cmake-args like colcon build --paths ../.. --metas ../.. --cmake-args -DCMAKE_BUILD_TYPE=Debug, the CMake projects are configured only with the cmake option specified with --cmake-args. colcon is not using default values.

dirk-thomas commented 5 years ago

As far as I understand your description I think this is intended behavior. A default value is a value which is used well by default if the user doesn't specify anything explicitly. If the user passes a custom value that will override the default value.

What you want to use instead is a mixin. Such configuration options are not defaults but will behave in the way you expect them to. When the user passes custom values they will be appended to the information defined in a selected mixin.

richiware commented 5 years ago

Ok. I've presumed the behaviour is to append, not to overwrite. Sorry. Maybe it is useful some comment in the help command. I have another question now I've discovered the "mixin" command. I will use this issue but I can open a new in the correct repository. I've tried to add a mixin in the default.yaml file.

{
    "build":
    {
        "mixin": ["ccache"]
    }
}

But it is not working. colcon is not using the mixin. Is it correct? Thanks

dirk-thomas commented 5 years ago

I've tried to add a mixin in the default.yaml file.

That use case work for me. I assume you have fetched the mixins and ccache appears in colcon mixin show build? Have you tried using the mixin manually: colcon build --mixin ccache?

richiware commented 5 years ago

I have the sample problem that with cmake-args. I have the ccache mixin in default.yaml because I want to enable ccache always. But at the same time I'm trying to build a project using the commandline argument --mixin rel-with-deb-info. The commandline argument is overwriting my default mixin. I suppose my use case is not supported. Thanks for your help.