`(blog ,garaemon)

ポップカルチャーを摂取して、コードを吐き出す機械

catkin profileが便利

catkin tools (catkinコマンド)を用いてソースコードをビルドする時に、ビルドオプションを変更したいことがあります。 たとえば、RelaseビルドとDebugビルドを切り替えたいときです。

このようなビルドオプションの切り替えには、catkin profileの機能が便利です。

catkin profileは異なるビルドオプションなどcatkin configの設定を保存することができます。

下のコマンドでは、RelWithDebInfoDebugというprofileに、それぞれのcmakeのオプションを設定しています。

catkin config --profile RelWithDebInfo --cmake-args -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CC_COMPILER_LAUNCHER=ccache -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
catkin config --profile Debug --cmake-args -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CC_COMPILER_LAUNCHER=ccache -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug

現在のprofileを確認するためには、catkin profile listというコマンドを利用します。

$ catkin profile list
[profile] Available profiles:
- default
- Debug
- RelWithDebInfo (active)

catkin configの先頭にも有効なprofileが表示されます。

$ catkin config
--------------------------------------------------------------------------------------------------------------------
Profile:                     RelWithDebInfo
Extending:          [cached] /opt/ros/melodic
Workspace:                   /home/garaemon/catkin_ws
(略)
Additional CMake Args:       -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CC_COMPILER_LAUNCHER=ccache -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
(略)

profileを切り替えるには、catkin profile setというコマンドを利用します。

$ catkin profile set RelWithDebInfo
[profile] Activated catkin metadata profile: RelWithDebInfo
[profile] Available profiles:
- default
- Debug
- RelWithDebInfo (active)