Added a flag for installing GeographicLib, and logic for using the built-in or installed GeographicLib, and disabling relevant unit tests in case GeographicLib is unavailable.

release/4.3a0
Richard Roberts 2014-02-25 15:46:25 -05:00
parent 1077a4b456
commit 42d5399b44
2 changed files with 40 additions and 3 deletions

View File

@ -33,4 +33,22 @@ add_subdirectory(metis-5.1.0)
# GeoidEval Gravity MagneticField Planimeter TransverseMercatorProj)
# add_subdirectory (tools)
add_subdirectory(GeographicLib)
# Find GeographicLib using the find script distributed with it
include(GeographicLib/cmake/FindGeographicLib.cmake)
# Set up the option to install GeographicLib
if(GEOGRAPHICLIB_FOUND)
set(install_geographiclib_default OFF)
else()
set(install_geographiclib_default ON)
endif()
option(GTSAM_INSTALL_GEOGRAPHICLIB "Build and install the 3rd-party library GeographicLib" ${install_geographiclib_default})
# Print warning if we'll overwrite GeographicLib
if(GEOGRAPHICLIB_FOUND AND GTSAM_INSTALL_GEOGRAPHICLIB)
message(WARNING "GeographicLib is installed on your system and GTSAM_INSTALL_GEOGRAPHICLIB is enabled. Installing gtsam will either overwrite the installed GeographicLib or install a second version that may conflict. You may want to disable GTSAM_INSTALL_GEOGRAPHICLIB if the installed version was not installed by GTSAM.")
endif()
if(GTSAM_INSTALL_GEOGRAPHICLIB)
add_subdirectory(GeographicLib)
endif()

View File

@ -1,3 +1,22 @@
include_directories(${PROJECT_SOURCE_DIR}/gtsam/3rdparty/GeographicLib/include)
set(test_link_libraries gtsam)
set(tests_excluded "")
gtsamAddTestsGlob(navigation "test*.cpp" "" "gtsam;GeographicLib")
# Decide whether to use installed GeographicLib or the one built in GTSAM.
# If we are not installing GeographicLib and it's not installed already,
# disable the unit tests that require it.
if(GTSAM_INSTALL_GEOGRAPHICLIB)
# If we're installing GeographicLib, use the one we're compiling
include_directories(${PROJECT_SOURCE_DIR}/gtsam/3rdparty/GeographicLib/include)
list(APPEND test_link_libraries GeographicLib)
else()
if(GEOGRAPHICLIB_FOUND)
# If we're not installing, but it's already installed, use the installed one
include_directories(${GeographicLib_INCLUDE_DIRS})
list(APPEND test_link_libraries ${GeographicLib_LIBRARIES})
else()
# We don't have GeographicLib
set(tests_excluded testGeographicLib.cpp testGPSFactor.cpp testMagFactor.cpp)
endif()
endif()
gtsamAddTestsGlob(navigation "test*.cpp" "${tests_excluded}" "${test_link_libraries}")