Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Commands in Linux || --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON #129

Open
Scoeerg opened this issue May 25, 2023 · 1 comment

Comments

@Scoeerg
Copy link

Scoeerg commented May 25, 2023

Hi,

ISSUE: Neither colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja nor colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON produce any ros2_ws/build/compile_commands.json.

on Ubuntu 20.04 LTS using ROS2 Foxy, colcon version-check:

colcon-argcomplete 0.3.3: up-to-date
colcon-bash 0.4.2: up-to-date
colcon-cd 0.1.1: up-to-date
colcon-cmake 0.2.27: up-to-date
colcon-core 0.12.1: up-to-date
colcon-defaults 0.2.8: up-to-date
colcon-devtools 0.2.3: up-to-date
colcon-installed-package-information 0.1.0: up-to-date
colcon-library-path 0.2.1: up-to-date
colcon-metadata 0.2.5: up-to-date
colcon-notification 0.2.15: up-to-date
colcon-output 0.2.13: up-to-date
colcon-override-check 0.0.1: up-to-date
colcon-package-information 0.3.3: up-to-date
colcon-package-selection 0.2.10: up-to-date
colcon-parallel-executor 0.2.4: up-to-date
colcon-pkg-config 0.1.0: up-to-date
colcon-powershell 0.3.7: up-to-date
colcon-python-setup-py 0.2.8: up-to-date
colcon-recursive-crawl 0.2.1: up-to-date
colcon-ros 0.3.23: up-to-date
colcon-test-result 0.3.8: up-to-date
colcon-zsh 0.4.0: up-to-date

especially colcon-cmake 0.2.27: up-to-date with

ros2_ws
  └── src
      └── cpp_pubsub
          ├── CMakeLists.txt
          ├── include
          │   └── cpp_pubsub
          ├── package.xml
          └── src

Neither colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja nor colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON produce any ros2_ws/build/compile_commands.json.

Output of colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja:

Starting >>> cpp_pubsub
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done      
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 0.9.11 (/opt/ros/foxy/share/ament_cmake/cmake)
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Found ament_lint_auto: 0.9.8 (/opt/ros/foxy/share/ament_lint_auto/cmake)
-- Added test 'copyright' to check source files copyright and LICENSE
-- Added test 'lint_cmake' to check CMake code style
-- Added test 'xmllint' to check XML markup files
-- Configuring done
-- Generating done
-- Build files have been written to: $mypath/ros_ws/build/cpp_pubsub
ninja: no work to do.
-- Install configuration: ""
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/ament_index/resource_index/package_run_dependencies/cpp_pubsub
-- Installing: /home/eric/Software/ros_ws/install/cpp_pubsub/share/ament_index/resource_index/parent_prefix_path/cpp_pubsub
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/environment/ament_prefix_path.sh
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/environment/ament_prefix_path.dsv
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/environment/path.sh
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/environment/path.dsv
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/local_setup.bash
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/local_setup.sh
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/local_setup.zsh
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/local_setup.dsv
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/package.dsv
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/ament_index/resource_index/packages/cpp_pubsub
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/cmake/cpp_pubsubConfig.cmake
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/cmake/cpp_pubsubConfig-version.cmake
-- Installing: $mypath/ros_ws/install/cpp_pubsub/share/cpp_pubsub/package.xml
Finished <<< cpp_pubsub [0.50s]                  

Summary: 1 package finished [0.60s]

Edit: #76 (comment) i.e. colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja --no-warn-unused-cli produces the same result.

Any suggestions?

Originally posted by @Scoeerg in #61 (comment)

@bertulli
Copy link

I just ran into the same problem, while following the same example codebase, if you are using the cpp_pubsub example from the documentation (I'm on ROS2 Humble, with WSL Ubuntu-22.04). However, I noticed that later in the tutorial it is shown that the build configuration files (both the CMakeLists.txt and the package.xml) are incomplete, and you're going to fill them in the tutorial. The compile_commands.json gets generated after. I wonder why this doesn't raise an error, and my guess is that in the CMake file there's no executable specified at first, therefore the build skips it entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants