Skip to content

This project can not be installed by colcon build #31

@felixf4xu

Description

@felixf4xu

Windows 11 and Visual Studio.

steps:

  1. create an empty workspace: d:\ws
  2. put this project to d:\ws\src\mrt_cmake_modules
  3. in d:\ws, run colcon build

error:

Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\colcon_core\executor_init_.py", line 91, in call
rc = await self.task(*args, **kwargs)
File "C:\Program Files\Python310\lib\site-packages\colcon_core\task_init_.py", line 93, in call
return await task_method(*args, **kwargs)
File "C:\Program Files\Python310\lib\site-packages\colcon_ros\task\catkin\build.py", line 75, in build
rc = await extension.build(
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\build.py", line 103, in build
rc = await self._build(
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\build.py", line 236, in build
if not await has_target(args.build_base, target):
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake_init
.py", line 62, in has_target
assert target == 'install'
AssertionError

for C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\__init__.py

async def has_target(path, target):
    """
    Check if the CMake generated build system has a specific target.

    :param str path: The path of the directory contain the generated build
      system
    :param str target: The name of the target
    :rtype: bool
    """
    generator = get_generator(path)
    if 'Unix Makefiles' in generator:
        return target in await get_makefile_targets(path)
    if 'Ninja' in generator:
        return target in get_ninja_targets(path)
    if 'Visual Studio' in generator:
        print(target)
        assert target == 'install'                                             <-- error
        install_project_file = get_project_file(path, 'INSTALL')
        return install_project_file is not None
    assert False, \
        "'has_target' not implemented for CMake generator '{generator}'" \
        .format_map(locals())

print(target) is for debug and its output is

tests

so assert target == 'install' failed

ps:
if I do a normal cmake --build (not colcon), it compiles ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions