diff --git a/.gitignore b/.gitignore index 2ac8abc..0ca1fcf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /install* /.gradle /gradleDir +toolchain \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f592cc..7233696 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,40 @@ set(CMAKE_OSX_ARCHITECTURES arm64 x86_64) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) project(thirdparty-gtsam) +include(FetchContent) + +# Fetch Eigen +set(EIGEN_BUILD_BLAS OFF) +set(EIGEN_BUILD_LAPACK OFF) +fetchcontent_declare( + Eigen3 + GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git + GIT_TAG 0fb2ed140d4fc0108553ecfb25f2d7fc1a9319a1 + GIT_PROGRESS TRUE +) +FetchContent_GetProperties(Eigen3) + +if(NOT Eigen3_POPULATED) + FetchContent_Populate(Eigen3) + + # Create a build directory for Eigen + set(eigen3_BUILD_DIR ${CMAKE_BINARY_DIR}/eigen3-build) + message("Eigen source is ${eigen3_SOURCE_DIR}, build is ${eigen3_BUILD_DIR}") + file(MAKE_DIRECTORY ${eigen3_BUILD_DIR}) + + # Configure Eigen + message("Hi configure - ${CMAKE_COMMAND} -S ${eigen3_SOURCE_DIR} -B ${eigen3_BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/eigen-install") + execute_process(COMMAND ${CMAKE_COMMAND} -S ${eigen3_SOURCE_DIR} -B ${eigen3_BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/eigen-install) + + # Build and install Eigen + message("Hi install") + execute_process(COMMAND ${CMAKE_COMMAND} --build ${EIGEN_BUILD_DIR} --target install) + message("bye install") +endif() + +# Set Eigen3_DIR to the installation location +set(Eigen3_DIR ${CMAKE_BINARY_DIR}/eigen-install/share/eigen3/cmake) + set(GTSAM_COMPILE_OPTIONS_PRIVATE_DEBUG CACHE INTERNAL FORCE) set(GTSAM_COMPILE_OPTIONS_PRIVATE_RELWITHDEBINFO CACHE INTERNAL FORCE) set(GTSAM_ENABLE_BOOST_SERIALIZATION OFF) @@ -18,11 +52,12 @@ set(GTSAM_BUILD_TESTS OFF) set(BUILD_SHARED_LIBS OFF) set(GTSAM_FORCE_SHARED_LIB OFF) set(GTSAM_FORCE_STATIC_LIB ON) +set(GTSAM_USE_SYSTEM_EIGEN ON) -include(FetchContent) fetchcontent_declare( gtsam - GIT_REPOSITORY https://github.com/mcm001/gtsam - GIT_TAG c24ca7951f1db4cfe4e23f368b2eda503de72176 + GIT_REPOSITORY https://github.com/calcmogul/gtsam + GIT_TAG 79960095b9d8e03dd9ee83d7e0c9cab810a05a72 + GIT_PROGRESS TRUE ) fetchcontent_makeavailable(gtsam) diff --git a/README.md b/README.md index b49d7e3..2c9cd55 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # Third party gtsam Third party gradle packaging for gtsam + +## Updating thirdparty library version + +Eigen is now a submodule here that we ask GTSAM to pull in using GTSAM_USE_SYSTEM_EIGEN. Change the submodule SHA to update Eigen.