From ce7b1ef7b420026ae7adb7e19afe8967dd75af0c Mon Sep 17 00:00:00 2001 From: Flavio De Vincenti Date: Tue, 16 Jan 2024 10:45:55 +0100 Subject: [PATCH] Simplify installation requirements --- CMakeLists.txt | 17 ----------------- UngarConfig.cmake.in | 31 +++---------------------------- external/CMakeLists.txt | 10 +++++----- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f75746a..fa528b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,23 +135,6 @@ if(UNGAR_BUILD_EXAMPLES) endif() if(UNGAR_INSTALL) - if(UNGAR_ENABLE_AUTODIFF) - if(NOT DEFINED CppAD_ROOT) - message( - STATUS - "To install Ungar, the prefix path of 'CppAD' must be provided as a CMake variable named 'CppAD_ROOT'. Using default value: '/usr/local'." - ) - set(CppAD_ROOT /usr/local) - endif() - if(NOT DEFINED CppADCodeGen_ROOT) - message( - STATUS - "To install Ungar, the prefix path of 'CppADCodeGen' must be provided as a CMake variable named 'CppADCodeGen_ROOT'. Using default value: '/usr/local'." - ) - set(CppADCodeGen_ROOT /usr/local) - endif() - endif(UNGAR_ENABLE_AUTODIFF) - include(GNUInstallDirs) # Install library headers. diff --git a/UngarConfig.cmake.in b/UngarConfig.cmake.in index fef0c7e..ed31ec8 100644 --- a/UngarConfig.cmake.in +++ b/UngarConfig.cmake.in @@ -23,23 +23,8 @@ if(@UNGAR_ENABLE_AUTODIFF@) find_dependency(FiniteDiff REQUIRED) # CppAD. - if(NOT EXISTS @CppAD_ROOT@) - message( - FATAL_ERROR - "Ungar installed with CMake variable 'CppAD_ROOT' set to '@CppAD_ROOT@', but the directory does not exist. Please set 'CppAD_ROOT' to a valid prefix path." - ) - endif() - - set(CPPAD_LIB_DIRECTORY @CppAD_ROOT@/lib) - set(CPPAD_INCLUDE_DIRECTORY @CppAD_ROOT@/include) - find_library( - CppAD_LIBRARY cppad_lib - PATHS ${CPPAD_LIB_DIRECTORY} REQUIRED - NO_DEFAULT_PATH) - find_path( - CppAD_INCLUDE_DIR cppad/cppad.hpp - PATHS ${CPPAD_INCLUDE_DIRECTORY} REQUIRED - NO_DEFAULT_PATH) + find_library(CppAD_LIBRARY cppad_lib REQUIRED) + find_path(CppAD_INCLUDE_DIR cppad/cppad.hpp REQUIRED) add_library(CppAD SHARED IMPORTED GLOBAL) add_library(CppAD::CppAD ALIAS CppAD) @@ -53,17 +38,7 @@ if(@UNGAR_ENABLE_AUTODIFF@) ${CppAD_LIBRARY_REAL_PATH}) # CppADCodeGen. - if(NOT EXISTS @CppADCodeGen_ROOT@) - message( - FATAL_ERROR - "Ungar installed with CMake variable 'CppADCodeGen_ROOT' set to '@CppADCodeGen_ROOT@', but the directory does not exist. Please set 'CppADCodeGen_ROOT' to a valid prefix path." - ) - endif() - set(CPPADCODEGEN_INCLUDE_DIRECTORY @CppADCodeGen_ROOT@/include) - find_path( - CppADCodeGen_INCLUDE_DIR cppad/cg.hpp - PATHS ${CPPADCODEGEN_INCLUDE_DIRECTORY} REQUIRED - NO_DEFAULT_PATH) + find_path(CppADCodeGen_INCLUDE_DIR cppad/cg.hpp REQUIRED) add_library(CppADCodeGen INTERFACE IMPORTED GLOBAL) add_library(CppADCodeGen::CppADCodeGen ALIAS CppADCodeGen) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 86ca889..9b0d98c 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -208,7 +208,8 @@ if(UNGAR_ENABLE_LOGGING) find_package(spdlog REQUIRED) endif() set_target_properties(spdlog::spdlog PROPERTIES IMPORTED_GLOBAL TRUE) - set_target_properties(spdlog::spdlog_header_only PROPERTIES IMPORTED_GLOBAL TRUE) + set_target_properties(spdlog::spdlog_header_only PROPERTIES IMPORTED_GLOBAL + TRUE) if(DEFINED SPDLOG_ROOT_DIRECTORY) message(STATUS "spdlog found at '${SPDLOG_ROOT_DIRECTORY}'.") @@ -267,8 +268,8 @@ if(UNGAR_ENABLE_AUTODIFF) PATHS ${CPPAD_INCLUDE_DIRECTORY} REQUIRED NO_DEFAULT_PATH) else() - # This line is bound to fail unless a helper CMake script is provided. - find_package(CppAD REQUIRED) + find_library(CppAD_LIBRARY cppad_lib REQUIRED) + find_path(CppAD_INCLUDE_DIR cppad/cppad.hpp REQUIRED) endif() if(DEFINED CPPAD_ROOT_DIRECTORY) @@ -308,8 +309,7 @@ if(UNGAR_ENABLE_AUTODIFF) PATHS ${CPPADCODEGEN_INCLUDE_DIRECTORY} REQUIRED NO_DEFAULT_PATH) else() - # This line is bound to fail unless a helper CMake script is provided. - find_package(CppADCodeGen REQUIRED) + find_path(CppADCodeGen_INCLUDE_DIR cppad/cg.hpp REQUIRED) endif() if(DEFINED CPPADCODEGEN_ROOT_DIRECTORY)