catkin profileが便利
catkin tools (catkinコマンド)を用いてソースコードをビルドする時に、ビルドオプションを変更したいことがあります。 たとえば、RelaseビルドとDebugビルドを切り替えたいときです。
このようなビルドオプションの切り替えには、catkin profileの機能が便利です。
catkin profileは異なるビルドオプションなどcatkin config
の設定を保存することができます。
下のコマンドでは、RelWithDebInfo
とDebug
という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)