CMake setting for SimpleControllers


#1

I have a question concerning CMake settings applied for SimpleControllers.

The function add_cnoid_simple_controller (defined in src/Body/CMakeLists.txt)
defines common settings for SimpleControllers.
My question is that why
apply_common_setting_for_target
is NOT called inside add_cnoid_simple_controller,
while it is commonly called for executables and libraries?

One particular problem I’m facing is that the dll names of SimpleControllers are
[SimpleControllerName].dll, no matter one builds in Debug or Release.
(for other files ‘d’ is appended to the filename to distinguish Debug from Release)
Because of this Debug/Release dlls are overwritten by each other every time I build in different modes. I feel it pretty inconvenient.

Is there any design decision behind this, or is this just a bug?


#2

We have to ask @nakaoka san about the specification, but the name of the controller is defined in the cnoid (yaml) file by its name:

And the path of the dll is resolved at this line, without adding any extra text to the defined name:

So if we output the controller dll in name “[SimpleControllerName]d.dll”, it will not be resolved any more when we load the project.

If we can add extra code in this line to switch its behavior, may be we can improve the usability. But the question is how?


#3

Thanks for the reply.
After thinking a little more after the previous post, now I think the current design
is not as inconvenient as I initially thought.

Anyway, I think the following controller name resolution rule is worth considering:

if (controller name specified in cnoid file includes extension (e.g. hoge.dll)
use this controller name as the file name of the shared library of the controller
else // controller name does not include extension (e.g. hoge)
if (choreonoid is built in DEBUG)
append d.dll (or d.so for linux) to the controller name and use this as the file name
else // choreonoid is buit in RELEASE
append .dll (or .so for linux) to the controller name and use this as the file name
endif
endif

I believe this rule will not cause any serious back-compatibility issue.