From 42d5399b4434b181265036b4efd8172f4ee10927 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 25 Feb 2014 15:46:25 -0500 Subject: [PATCH] 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. --- gtsam/3rdparty/CMakeLists.txt | 20 +++++++++++++++++++- gtsam/navigation/tests/CMakeLists.txt | 23 +++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gtsam/3rdparty/CMakeLists.txt b/gtsam/3rdparty/CMakeLists.txt index 581ca3ad2..31947838d 100644 --- a/gtsam/3rdparty/CMakeLists.txt +++ b/gtsam/3rdparty/CMakeLists.txt @@ -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() diff --git a/gtsam/navigation/tests/CMakeLists.txt b/gtsam/navigation/tests/CMakeLists.txt index a9bf98a5a..2f3c0883a 100644 --- a/gtsam/navigation/tests/CMakeLists.txt +++ b/gtsam/navigation/tests/CMakeLists.txt @@ -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}")