Git Product home page Git Product logo

Comments (9)

kutschkem avatar kutschkem commented on August 20, 2024 1

ExternalProject_Add did indeed help, thank you very much! I also found the CMake option to disable the Uninstall target generation -DAMENT_CMAKE_UNINSTALL_TARGET=OFF

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

When calling find_package(xxx) multiple time in CMake the CMake config file is normally not being re-invoked. Can you please post an example how you are using it / where you are calling it multiple times.

from ament_cmake.

kutschkem avatar kutschkem commented on August 20, 2024

I am writing a code generator that generates a CMake project with several subprojects that get included with add_subdirectory. Each subproject defines ROS messages and builds them with ament.

So the structure looks somewhat like this:

| - CMakeLists.txt
| - subproject1/CMakeLists.txt
| - subproject1/package.xml
| - subproject1/msg/Messages1.msg
| - subproject2/CMakeLists.txt
| - subproject2/package.xml
| - subproject2/msg/Messages2.msg

Inside the subproject, I call find_package(ament_cmake). Because there can be other subprojects that don't use ament, I thought that having the subproject find the package it depends on is the clean way.

The problem here, I think, is that the variable used to track whether ament was already included has a scope that only includes the subproject, but targets have global scope (or so is my understanding). See this answer on StackOverflow. What that would mean is that variables need to be set again, but target should not be redefined.

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

In general we don't recommend to run multiple ROS 2 packages in a single CMake context which seems to be what you are doing here. There are many other problems related to that. E.g. a package B having a dependency on package A expects that A has finished building already and is available to be used. In a single CMake context that is not ensured since your targets in package B (should) have no knowledge or explicit CMake dependencies on targets in package A.

That being saif please feel free to wrap the creation of the uninstall target in a condition check that the target doesn't exist already (

) and create a pull request for this.

from ament_cmake.

kutschkem avatar kutschkem commented on August 20, 2024

... or I could try to do it the intended way. What is the intended way a multi-package project should be built?

from ament_cmake.

kutschkem avatar kutschkem commented on August 20, 2024

I will try to work around this with add_custom_target to implement the workflow mentioned in
#56 (comment)
and have it called by my toplevel cmake.

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

What is the intended way a multi-package project should be built?

The recommended way is to use a build tool like ament_tools which builds each package separately in the right order. As an alternative you can also do that manually buy invoking cmake / make / make install on each package in the right order (and potentially set any environment variables in between to find the dependencies when not installing to a standard location like /usr).

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

I will try to work around this with add_custom_target to implement the workflow mentioned in #56 (comment) and have it called by my toplevel cmake.

I don't think that this will work in a single CMake invocation due to target collisions in a single CMake context and missing target dependency across package boundaries. The build tool is already implementing this process for you - just not in a single CMake context but by invoking CMake separately for each package.

from ament_cmake.

wjwwood avatar wjwwood commented on August 20, 2024

The closest analog to ament_tools which doesn't use it would be ExternalProject_Add, with proper dependencies between projects and any steps in between needed for them to find one another after being built. Note you can call ExternalProject_Add on local paths, so you don't have to download with that command. I think this project does something like this:

https://github.com/Sarcasm/cmake-superbuild

But I've never tried it or know if it would work for our sources.

from ament_cmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.