diff --git a/CMakeLists.txt b/CMakeLists.txt index f10ff33..9f45bb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,36 +46,43 @@ endif() ## then AUTODIFF if (USE_AUTODIFF) - message("-- Trying to find autodiff. Turn off via setting 'USE_AUTODIFF=OFF' in your environment before installation. ") - find_package(autodiff) - if (autodiff_FOUND) - message("-- global installation of the autodiff library found: attempting to find Eigen3.") - else() - message("-- no global installation of autodiff library found. Trying to include it as a submodule.") - set(INTERNAL_findautodiff_DIR ${PROJECT_SOURCE_DIR}/extern/autodiff) - if(NOT EXISTS ${INTERNAL_findautodiff_DIR}) - message("The autodiff submodule was not found! Please run 'git submodule update --init'. Alternatively you can install autodiff globally on your system." ) + + + find_package(Eigen3 REQUIRED NO_MODULE) + if(NOT Eigen3_FOUND) + message("-- Could not find Eigen3 library globally! Trying to include it as a submodule.") + set(EIGEN_PATH ${PROJECT_SOURCE_DIR}/extern/Eigen) + if(NOT EXISTS ${EIGEN_PATH}) + message("The Eigen3 submodule was not found! Please run 'git submodule update --init'. Alternatively you can try to set the EIGEN_PATH to the eigen header files manually. Will proceed without autodiiferentiation." ) set(USE_AUTODIFF OFF) else() - add_subdirectory(${INTERNAL_findautodiff_DIR}) - message("-- autodiff library found as a submodule. Tests will be compiled.") - set(autodiff_FOUND ON) + message("-- Eigen3 library found as a submodule. Tests will be compiled.") + set(Eigen3_FOUND ON) endif() + else() + message("-- Eigen3 library at ${EIGEN_PATH} found.") endif() - if (autodiff_FOUND) - - find_package(Eigen3 REQUIRED NO_MODULE) + if (Eigen3_FOUND) set(autodiff_INCLUDE_DIRS ${EIGEN_PATH}) - if(NOT Eigen3_FOUND) - message("-- Could not find the Eigen3 library! Autodifferention disabled.") - else() - message("-- Eigen3 library found: Autodifferention enabled.") - endif() - else() - message("-- Could not find the autodiff library! Autodifferention disabled.") + message("-- Trying to find autodiff. Turn off via setting 'USE_AUTODIFF=OFF' in your environment before installation. ") + find_package(autodiff) + if (autodiff_FOUND) + message("-- global installation of the autodiff library found: attempting to find Eigen3.") + else() + message("-- no global installation of autodiff library found. Trying to include it as a submodule.") + set(INTERNAL_findautodiff_DIR ${PROJECT_SOURCE_DIR}/extern/autodiff) + if(NOT EXISTS ${INTERNAL_findautodiff_DIR}) + message("The autodiff submodule was not found! Please run 'git submodule update --init'. Alternatively you can install autodiff globally on your system." ) + set(USE_AUTODIFF OFF) + else() + add_subdirectory(${INTERNAL_findautodiff_DIR}) + message("-- autodiff library found as a submodule. Tests will be compiled.") + set(autodiff_FOUND ON) + endif() + endif() endif() else() set(autodiff_FOUND OFF)