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

Add CMake exported targets #140

Merged
merged 1 commit into from
Oct 11, 2016
Merged

Add CMake exported targets #140

merged 1 commit into from
Oct 11, 2016

Conversation

jamiesnape
Copy link
Contributor

Makes it easier to use OctoMap in other CMake projects (and avoids issues like #138).

@ahornung
Copy link
Member

@jamiesnape Could you quickly outline what this means for libs depending on CMake, how they can or must use it?

Is this a (potentially) breaking change that needs to go into a new Minor version, or is a new Patch release sufficient?

@jamiesnape
Copy link
Contributor Author

jamiesnape commented Oct 11, 2016

It is not a breaking change. Projects can continue to use the current logic, so a patch release is fine.

As well as:

find_package(octomap)
if(octomap_FOUND)
  add_executable(foo foo.c)
  target_include_directories(foo ${OCTOMAP_INCLUDE_DIRS})
  target_link_libraries(foo ${OCTOMAP_LIBRARIES})
endif()

you could also use:

find_package(octomap)
if(octomap_FOUND)
  add_executable(bar bar.c)
  target_link_libraries(bar octomap)
endif()

or to link with the static library:

find_package(octomap)
if(octomap_FOUND)
  add_executable(foobar foobar.c)
  target_link_libraries(foobar octomap-static)
endif()

(no call to include_directories() or target_include_directories() required, nor is octomath required to be added to the target_link_libraries() call.)

This would also be correct:

if(TARGET octomap-static)
  add_executable(foobar foobar.c)
  target_link_libraries(foobar octomap-static)
endif()

@ahornung
Copy link
Member

Cool, thanks!

@ahornung ahornung merged commit 6d7c31a into OctoMap:devel Oct 11, 2016
@jamiesnape jamiesnape deleted the cmake-exported-targets branch October 11, 2016 20:47
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

Successfully merging this pull request may close these issues.

2 participants