Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/juanmanzanero/lion-cpp into…
Browse files Browse the repository at this point in the history
… main
  • Loading branch information
diegolodares committed Nov 30, 2023
2 parents e7fc6a1 + ee789d7 commit 8d89bfe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ target_include_directories(lion SYSTEM INTERFACE
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/lion/thirdparty/include>"
)

target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries)
target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries cppad)

# Create a lion header only
add_library(header_only INTERFACE)
Expand Down Expand Up @@ -104,7 +104,7 @@ install(FILES ${version_file} ${config_file}
DESTINATION ${cmake_files_install_dir})

# Export the targets
install(TARGETS lion ipopt blaslapack tinyxml2 header_only fortran_libraries
install(TARGETS lion ipopt blaslapack tinyxml2 header_only fortran_libraries cppad
EXPORT ${targets_export_name}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
31 changes: 29 additions & 2 deletions cmake/Findcppad.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
if (NOT cppad_FOUND)
find_path(CPPAD_INCLUDE_DIR cppad.hpp PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/include/cppad)

if (CPPAD_INCLUDE_DIR)

find_library(CPPAD_LIBRARY NAMES cppad_lib PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib HINTS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib NO_DEFAULT_PATH)

if (CPPAD_INCLUDE_DIR AND CPPAD_LIBRARY)
set(cppad_FOUND YES)

get_filename_component(CPPAD_LIB_NAME ${CPPAD_LIBRARY} NAME)

if (APPLE)
# Change relative paths by absolute path
execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -id "@rpath/${CPPAD_LIB_NAME}" ${CPPAD_LIBRARY})
endif()


add_library(cppad INTERFACE)


file(GLOB CPPAD_LIB_ALL_FILES "${CMAKE_BINARY_DIR}/lion/thirdparty/lib/libcppad_lib*")

set(CPPAD_LIBRARY_INSTALL ${CMAKE_INSTALL_FULL_LIBDIR}/${CPPAD_LIB_NAME})

target_link_libraries(cppad INTERFACE
"$<BUILD_INTERFACE:${CPPAD_LIBRARY}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_LIBDIR}/${CPPAD_LIB_NAME}>")


foreach(t ${CPPAD_LIB_ALL_FILES})
install(FILES "${t}" TYPE LIB)
endforeach()

else()
set(cppad_FOUND NO)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/compilerflags.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_compile_options(-Wfatal-errors -Werror -Wall)
add_compile_options(-Wfatal-errors -Werror -Wall -DCPPAD_DEBUG_AND_RELEASE)

if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_options(-O0 -gdwarf-2)
Expand Down
4 changes: 2 additions & 2 deletions cmake/third-party/cppad.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ if ( ${BUILD_CPPAD} )
include (ExternalProject)
ExternalProject_Add(cppad
GIT_REPOSITORY https://github.com/coin-or/CppAD.git
GIT_TAG 6856fdde535d2a7634a6fc36d8787a72166dce91
GIT_TAG master
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${THIRD_PARTY_DIR}/lion/thirdparty -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
PREFIX "${THIRD_PARTY_DIR}/cppad"
SOURCE_DIR ${THIRD_PARTY_DIR}/cppad/source
BINARY_DIR ${THIRD_PARTY_DIR}/cppad/build
INSTALL_DIR ${THIRD_PARTY_DIR}/lion/thirdparty
)
add_dependencies(cppad ipopt)
# add_dependencies(cppad ipopt)

endif()

0 comments on commit 8d89bfe

Please sign in to comment.