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

For anyone facing Qt5-related errors when running colcon build -- SOLUTION HERE #4

Open
deniscalin opened this issue Oct 26, 2024 · 0 comments

Comments

@deniscalin
Copy link

Hello!

This installation worked well, and I am successfully running Ros2 Jazzy on Mac M2 Sonoma 14.5, which is great.

When going through the official Ros2 Create Workspace tutorials, I started running into the following error related to a homebrew-installed Qt5 when trying to build a turtlesim package with colcon build:

-- Configuring incomplete, errors occurred!
--- stderr: turtlesim
CMake Error at CMakeLists.txt:16 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of
  the following names:

  Qt5Config.cmake
  qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.


---
Failed   <<< turtlesim [6.65s, exited with code 1]

I was able to figure out a solution, SOLUTION HERE:

  1. Run brew --prefix qt@5 to find your Qt5 installation directory. Save that full path for later.
  2. Find and open the CMakeLists.txt file of the package you are installing. For turtlesim, it was in the src/ros_tutorials/turtlesim path relative to my workspace directory.
  3. Add the following line to the CMakeLists.txt file, and save:
    set(CMAKE_PREFIX_PATH "{your_qt5_prefix_from_step_1}/lib/cmake")

Essentially you want to add the full path to the package's cmake directory to the CMAKE_PREFIX_PATH. For example, to resolve the error related to Qt5, I added the following line to the CMakeLists.txt file and saved:
set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt@5/lib/cmake")

I've added that line closer to the top of the file, before all of the find_package statements.

And that's it! After this my package built successfully. This could potentially work for other CMakeLists.txt-related errors

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

No branches or pull requests

1 participant