Skip to content

Commit

Permalink
Simplify installation requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
fdevinc committed Jan 16, 2024
1 parent 2f8a537 commit ce7b1ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 50 deletions.
17 changes: 0 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 3 additions & 28 deletions UngarConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}'.")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ce7b1ef

Please sign in to comment.