Skip to content

Commit

Permalink
Merge pull request #137 from Ellon/fix/GTSAMConfigVersion.cmake_for_4…
Browse files Browse the repository at this point in the history
….0.2

Fix GTSAM version detection for 4.0.2
  • Loading branch information
varunagrawal authored Oct 8, 2019
2 parents a28806b + 0aaf496 commit 342f30d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 181 deletions.
28 changes: 26 additions & 2 deletions cmake/GtsamMakeConfigFile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,37 @@ function(GtsamMakeConfigFile PACKAGE_NAME)
set(EXTRA_FILE "_does_not_exist_")
endif()

# GTSAM defines its version variable as GTSAM_VERSION_STRING while other
# projects may define it as <ProjectName>_VERSION. Since this file is
# installed on the system as part of GTSAMCMakeTools and may be useful in
# external projects, we need to handle both cases of version variable naming
# here.
if(NOT DEFINED ${PACKAGE_NAME}_VERSION AND DEFINED ${PACKAGE_NAME}_VERSION_STRING)
set(${PACKAGE_NAME}_VERSION ${${PACKAGE_NAME}_VERSION_STRING})
endif()

# Version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}ConfigVersion.cmake"
VERSION ${${PACKAGE_NAME}_VERSION}
COMPATIBILITY SameMajorVersion
)

# Config file
file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
file(RELATIVE_PATH CONF_REL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/lib")
configure_file(${GTSAM_CONFIG_TEMPLATE_PATH}/Config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake" @ONLY)
message(STATUS "Wrote ${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake")

# Install config and exports files (for find scripts)
install(FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}")
# Install config, version and exports files (for find scripts)
install(
FILES
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}ConfigVersion.cmake"
DESTINATION
"${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}"
)
install(EXPORT ${PACKAGE_NAME}-exports DESTINATION ${DEF_INSTALL_CMAKE_DIR})

endfunction()
88 changes: 0 additions & 88 deletions cmake/obsolete/FindGTSAM.cmake

This file was deleted.

88 changes: 0 additions & 88 deletions cmake/obsolete/FindGTSAM_UNSTABLE.cmake

This file was deleted.

5 changes: 2 additions & 3 deletions gtsam_extra.cmake.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Extra CMake definitions for GTSAM

set (GTSAM_VERSION_MAJOR @GTSAM_VERSION_MAJOR@)
set (GTSAM_VERSION_MINOR @GTSAM_VERSION_MINOR@)
set (GTSAM_VERSION_PATCH @GTSAM_VERSION_PATCH@)
# All version variables are handled by GTSAMConfigVersion.cmake, except these
# two below. We continue to set them here in case someone uses them
set (GTSAM_VERSION_NUMERIC @GTSAM_VERSION_NUMERIC@)
set (GTSAM_VERSION_STRING "@GTSAM_VERSION_STRING@")

Expand Down

0 comments on commit 342f30d

Please sign in to comment.