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

Make g2o headers relocatable by using build/install placeholders #390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ if(APPLE)
endif(APPLE)

# Set the output directory for the build executables and libraries
set(g2o_RUNTIME_OUTPUT_DIRECTORY ${g2o_SOURCE_DIR}/bin CACHE PATH "Target for the binaries")
set(g2o_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "Target for the binaries")
if(WIN32)
set(g2o_LIBRARY_OUTPUT_DIRECTORY ${g2o_SOURCE_DIR}/bin CACHE PATH "Target for the libraries")
set(g2o_LIBRARY_OUTPUT_DIRECTORY $${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "Target for the libraries")
else(WIN32)
set(g2o_LIBRARY_OUTPUT_DIRECTORY ${g2o_SOURCE_DIR}/lib CACHE PATH "Target for the libraries")
set(g2o_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib CACHE PATH "Target for the libraries")
endif(WIN32)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${g2o_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${g2o_LIBRARY_OUTPUT_DIRECTORY})
Expand Down Expand Up @@ -355,7 +355,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${g2o_C_FLAGS}")
# Find Eigen3. If it defines the target, this is used. If not,
# fall back to the using the module form.
# See https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html for details
find_package(Eigen3 REQUIRED)
find_package(Eigen3 REQUIRED NO_MODULE)
if (TARGET Eigen3::Eigen)
set(G2O_EIGEN3_EIGEN_TARGET Eigen3::Eigen)
else()
Expand Down
8 changes: 6 additions & 2 deletions EXTERNAL/csparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ if (UNIX)
target_link_libraries(csparse PUBLIC m)
endif()

# Make it relocatable.
target_include_directories(csparse INTERFACE
$<INSTALL_INTERFACE:include/g2o/csparse>
)

install(TARGETS csparse
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
install(FILES ${headers} DESTINATION ${INCLUDES_INSTALL_DIR}/EXTERNAL/csparse)
install(FILES ${headers} DESTINATION ${INCLUDES_INSTALL_DIR}/csparse)

# Set up the variables
set(CSPARSE_LIBRARY "$<TARGET_FILE:csparse>")
Expand Down
5 changes: 4 additions & 1 deletion EXTERNAL/freeglut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ if (APPLE)
set_target_properties(freeglut_minimal PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()

target_include_directories(freeglut_minimal INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/freeglut>)

install(TARGETS freeglut_minimal
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
9 changes: 7 additions & 2 deletions g2o/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ robust_kernel_factory.cpp robust_kernel_factory.h
g2o_core_api.h
)


target_link_libraries(core PUBLIC stuff ${G2O_EIGEN3_EIGEN_TARGET} )

set_target_properties(core PROPERTIES OUTPUT_NAME ${LIB_PREFIX}core)
target_link_libraries(core PUBLIC stuff ${G2O_EIGEN3_EIGEN_TARGET})

if (APPLE)
set_target_properties(core PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()

target_include_directories(core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS core
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/solvers/csparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ target_link_libraries(solver_csparse
PUBLIC csparse_extension
PUBLIC core)

target_include_directories(solver_csparse PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

install(TARGETS solver_csparse csparse_extension
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)
file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
install(FILES ${headers} DESTINATION ${INCLUDES_INSTALL_DIR}/solvers/csparse)
5 changes: 4 additions & 1 deletion g2o/solvers/dense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ endif()

target_link_libraries(solver_dense core)

target_include_directories(solver_dense PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS solver_dense
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/solvers/eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ if (APPLE)
endif()
target_link_libraries(solver_eigen core)

target_include_directories(solver_eigen PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS solver_eigen
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/solvers/pcg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ endif()

target_link_libraries(solver_pcg core)

target_include_directories(solver_pcg PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS solver_pcg
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/solvers/slam2d_linear/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ endif()

target_link_libraries(solver_slam2d_linear solver_csparse types_slam2d)

target_include_directories(solver_slam2d_linear PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS solver_slam2d_linear
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/solvers/structure_only/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ endif()

target_link_libraries(solver_structure_only core)

target_include_directories(solver_structure_only PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS solver_structure_only
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
10 changes: 8 additions & 2 deletions g2o/stuff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ add_library(stuff ${G2O_LIB_TYPE}
set_target_properties(stuff PROPERTIES OUTPUT_NAME ${LIB_PREFIX}stuff)
target_link_libraries(stuff PUBLIC ${G2O_EIGEN3_EIGEN_TARGET})

target_include_directories(stuff PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

if (APPLE)
set_target_properties(stuff PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()
Expand All @@ -22,7 +26,6 @@ install(TARGETS stuff
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

# build our OpenGL helper library
Expand All @@ -38,11 +41,14 @@ endif()
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

target_link_libraries(opengl_helper PUBLIC ${G2O_OPENGL_TARGET} ${G2O_EIGEN3_EIGEN_TARGET})
set_target_properties(opengl_helper PROPERTIES OUTPUT_NAME "${LIB_PREFIX}opengl_helper")

target_include_directories(opengl_helper PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT ANDROID)
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_data freeglut_minimal opengl_helper)
endif()

target_include_directories(types_data PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_data
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/icp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ if (APPLE)
endif()
target_link_libraries(types_icp types_sba types_slam3d)

target_include_directories(types_icp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_icp
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/sba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ if (APPLE)
endif()
target_link_libraries(types_sba core types_slam3d)

target_include_directories(types_sba PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_sba
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
4 changes: 4 additions & 0 deletions g2o/types/sclam2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_sclam2d ${OPENGL_gl_LIBRARY})
endif()

target_include_directories(types_sclam2d PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_sclam2d
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/sim3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ if (APPLE)
endif()
target_link_libraries(types_sim3 PUBLIC types_sba)

target_include_directories(types_sim3 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_sim3
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/slam2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_slam2d opengl_helper ${OPENGL_gl_LIBRARY} )
endif()

target_include_directories(types_slam2d PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_slam2d
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/slam2d_addons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_slam2d_addons ${OPENGL_gl_LIBRARY})
endif()

target_include_directories(types_slam2d_addons PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_slam2d_addons
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
5 changes: 4 additions & 1 deletion g2o/types/slam3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_slam3d opengl_helper ${OPENGL_gl_LIBRARY} )
endif()

target_include_directories(types_slam3d PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

install(TARGETS types_slam3d
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down
6 changes: 5 additions & 1 deletion g2o/types/slam3d_addons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ if(G2O_HAVE_OPENGL)
target_link_libraries(types_slam3d_addons ${OPENGL_gl_LIBRARY} )
endif()

target_include_directories(types_slam3d_addons PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

install(TARGETS types_slam3d_addons
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
LIBRARY DESTINATION ${LIBRARY_DESTINATION}
ARCHIVE DESTINATION ${ARCHIVE_DESTINATION}
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
Expand Down