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

Build failure when CMAKE_PROJECT_NAME is not set #124

Open
cottsay opened this issue May 17, 2021 · 1 comment
Open

Build failure when CMAKE_PROJECT_NAME is not set #124

cottsay opened this issue May 17, 2021 · 1 comment

Comments

@cottsay
Copy link
Member

cottsay commented May 17, 2021

There's some code in colcon_cmake which skips the package build when CMAKE_PROJECT_NAME is not set or could not be detected. When this case is triggered and the warning is printed because the cache is not readable, the code in colcon_ros tries to detect the availability of an install target, but fails to do so as this requires reading the cache as well. There appears to be an attempt to suppress this sort of error if the build invocation failed, but because of how colcon_cmake returned without an error, this logic fails and a backtrace is printed.

# if the build has failed getting targets might not be possible
try:
has_install_target = await has_target(args.build_base, 'install')
except Exception: # noqa: B902
if not rc:
raise
has_install_target = False

[2.863s] colcon.colcon_cmake.task.cmake.build WARNING Could not build CMake package 'foobar' because the CMake cache has no 'CMAKE_PROJECT_NAME' variable
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/colcon_ros/task/ament_cmake/build.py", line 65, in build
    has_install_target = await has_target(args.build_base, 'install')
  File "/usr/lib/python3.9/site-packages/colcon_cmake/task/cmake/__init__.py", line 56, in has_target
    if 'Unix Makefiles' in generator:
TypeError: argument of type 'NoneType' is not iterable

The situation that led to this state was initially caused by user error, in which I had accidentally left the remnants of a prior invocation of CMake within the package sources. Removing these files resolved that specific issue.

@rsarrazin2
Copy link

rsarrazin2 commented Jun 23, 2022

Note that in my case, colcon's not finding the CMake cache variable CMAKE_PROJECT_NAME was due to its expecting CMakeCache.txt in the "wrong" folder. You can find the full description in my self-answered question How can I make colcon work with a plain preset-based CMake project with multiple presets in parallel?.

I add this comment here because that's where I landed searching for my problem.

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