Skip to content

Conversation

@schweitzer
Copy link

Hello,

I've made some changes in the CMakeLists of g2o and I though it could be interesting to share it.

First I've set output directory to the BUILD_DIR instead of g2o_SOURCE_DIR.

Then I've updated most of the g2o modules headers to be relocatable (in a modern cmake way) by using placeholders. Before headers paths was hard-coded in the generated g2oTargets.cmake, and with this modification path are relatives to the install path.

Example with stuff module

before:

(g2oTragets.cmake)
...
 # Create imported target g2o::stuff
 add_library(g2o::stuff SHARED IMPORTED)
 
 set_target_properties(g2o::stuff PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "/home/mschweitzer/dev/others/install/g2o/release/include"
 )

after:

(g2oTragets.cmake)
...
 # Create imported target g2o::stuff
 add_library(g2o::stuff SHARED IMPORTED)
 
 set_target_properties(g2o::stuff PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
 )

the ${_IMPORT_PREFIX} is automatically generated by CMake and is relative to the install directory.

I think this is much more convenient to deal with transitive dependencies (when using for example ORB_SLAM2, OpenVSLAM, etc...).

I didn't check all the corner-case of g2o library, so let my know if there is anything wrong with this PR.

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.

1 participant