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

Adding-to-Other-Software link dead in wiki #22

Open
htp2 opened this issue Dec 1, 2022 · 1 comment
Open

Adding-to-Other-Software link dead in wiki #22

htp2 opened this issue Dec 1, 2022 · 1 comment

Comments

@htp2
Copy link

htp2 commented Dec 1, 2022

Hi Rob, hope you are well.

I noticed the link in one of the FAQs in the wiki does not work. I was hoping to use xreg as a dependency for other code, was having some issues, and thought that whatever may have been linked here in the past could have been helpful. I've replicated the portion on the wiki below:

How do I incorporate this library into my software?
The xReg library is most easily incorporated using standard CMake practices, such as add_subdirectory() and find_package(). See this page for more details.

I will briefly ask your opinion on what I am trying to do and see if you have a quick suggestion:
I have been using / expanding on some of Cong's 2d/3d CM registration work. I would prefer not to continue using an 'unofficial fork' of xreg as has been done to this point, but rather build xreg and then use it as a dependency for any custom code development. This development doesn't lend itself to living within xreg (e.g. specific applications for our robot and ROS wrappers for triggering image registration, etc.).

At the moment, the plan is as follows:
Build xreg e.g. at ~/xreg/ and then have a separate package e.g. at ~/cm_robot_regi/ that would find and use xreg as a dependency.

An excerpt from the CMakeLists for cm_robot_regi might be something like (where test.cpp has some xreg includes):

project(cm_robot_regi)
cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)
set (CMAKE_CXX_STANDARD "17" CACHE STRING "C++ Standard (needs at least 17)")
find_package(xreg REQUIRED HINTS ~/xreg/build)
add_executable(TEST_EXE test.cpp)
target_link_libraries(TEST_EXE xreg::xreg)

This doesn't work as I've written it, at the moment it seems like I may need to add additional find_package() for e.g. VTK, ITK, etc. (I get cmake errors expecting links to e.g. VTK::XYZ whenever I do the target_link_libraries()). I'm pursuing this avenue, but I feel I might be missing the big picture here.

I'm interested in your thoughts: 1) does this approach make sense? and 2) do you have a better suggested method for doing it if so?

Thanks!

@rg2
Copy link
Owner

rg2 commented Dec 3, 2022

Hi Henry,

Thanks a lot for your comment, it's nice to hear from you.

I'm sorry that I have not written the wiki page yet for this question, but maybe by working on this we can have a good example to use.

I think your approach makes sense. You can see on this repository that I have a collection of other applications that link to a version of xreg that is built separate. In that CMakeLists.txt, the find_packages for ITK and VTK are done AFTER the find_package for xreg.

I would try the following (at least to get started):

  1. Perform builds of dependencies (ITK/VTK/etc.) (see the example scripts for examples of how to do this) and install them in a local directory (I recommend trying static libraries).
  2. Build xreg as a static library, do not install it,
  3. For the new software, use CMAKE_PREFIX_PATH either as an environment variable or CMake variable to point to your dependencies and xreg build. This will avoid incompatible system versions being given preference.
  4. If any of the libraries show up as not found during CMake manually set them (when using static libraries, specifying their build directories typically works well)
  5. Hopefully, you do not have linker errors now.

I can see this having problems if your other software has the same dependencies, but conflicting versions. Is that the case here?

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

2 participants