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

Provide CMake exported targets #116

Conversation

mwoehlke-kitware
Copy link
Contributor

Modify build/install rules to provide a CMake package configuration file with modern exported targets. This makes it much easier for users to use FCL:

find_package(fcl)
target_link_libraries(myapp fcl) # takes care of includes too!

I wrote this in a way that the new logic only takes effect when compiled with a more recent version of CMake, because I wasn't sure of the impact of bumping the minimum required CMake version. If it's okay with the project to require 2.8.12, please let me know and I can simplify the logic accordingly.

Modify build/install rules to provide a CMake package configuration file
with modern exported targets. This makes it much easier for users to use
FCL.
@sherm1
Copy link
Member

sherm1 commented Apr 4, 2016

Thanks, Matthew! My preference would be to require CMake >= 2.8.12 and simplify the logic. Does anyone object to that?

@sherm1
Copy link
Member

sherm1 commented Apr 4, 2016

If I'm reading this correctly the default CMake for Ubuntu 14.04 is 2.8.12.

@sherm1
Copy link
Member

sherm1 commented Apr 4, 2016

Linux CI builds failed.

When present, octomap needs to be a public link dependency. Change the
target_link_libraries accordingly.
Bump minimum required CMake version. Simplify logic to generate exported
targets accordingly.
@mwoehlke-kitware
Copy link
Contributor Author

My preference would be to require CMake >= 2.8.12 and simplify the logic.

Done, as a separate commit so I can easily back it out again if there are objections. Hopefully the CI is also fixed (I don't have octomap in my build which is why it was working on my machine).

ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(EXPORT ${PROJECT_NAME}Config
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this installation location, fclConfig.cmake will not be found automatically on Windows even if the system CMAKE_PREFIX_PATH enviromental variable matches the CMAKE_INSTALL_PREFIX of fcl. [1]
Modifying the code as in [2] :

if(WIN32 AND NOT CYGWIN)
  set(_EXPORT_INSTALL_DESTINATION CMake)
else()
  set(_EXPORT_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
endif()

install(EXPORT ${PROJECT_NAME}Config
        DESTINATION ${_EXPORT_INSTALL_DESTINATION})

will ensure that the library will be easily found also in Windows.

[1] : https://cmake.org/cmake/help/v3.0/command/find_package.html
[2] : https://github.com/robotology/ycm/blob/master/modules/InstallBasicPackageFiles.cmake#L176

Change the install destination for the CMake package configuration file
to use, on Windows, a location that is searched by default on Windows.
(The prior logic only worked for UNIX platforms.)

With thanks to Silvio Traversaro for the suggestion.
@mwoehlke-kitware
Copy link
Contributor Author

Ping? CI passes now. Is this just waiting on a suitable period for objections to elapse, or is there something else I should change?

@sherm1
Copy link
Member

sherm1 commented Apr 8, 2016

Ping? CI passes now.

Sorry, GitHub doesn't notify when new commits are pushed so I don't think anyone noticed this is ready. A ping definitely helps!

Thanks, Matthew!

@sherm1 sherm1 merged commit 0cd30df into flexible-collision-library:master Apr 8, 2016
@mwoehlke-kitware mwoehlke-kitware deleted the cmake-export-targets branch April 8, 2016 15:36
@mwoehlke-kitware
Copy link
Contributor Author

Thanks, @sherm1!

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.

4 participants