Skip to content

Commit

Permalink
Install ipopt dependencies in ipopt folder to reduce book-keeping (#3920
Browse files Browse the repository at this point in the history
)

* Install ipopt dependencies in ipopt folder to reduce unnecessary book-keeping

* Update CMakeLists.txt

Replicate fix to install script on linux to account for new library locations

* install libfortran and quadmath on apple

* Install libgcc from same folder as libgfortran on osx

* Update CMakeLists.txt

Add comments and remove unused/stale lines from OSX install commands

* Remove debugging and comment lines

---------

Co-authored-by: Ayman <[email protected]>
  • Loading branch information
aymanhab and Ayman authored Oct 9, 2024
1 parent c9336a8 commit 9595a4a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
36 changes: 21 additions & 15 deletions Vendors/tropter/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@

if(TROPTER_COPY_DEPENDENCIES AND APPLE)
get_filename_component(gcc_libdir "${pkgcfg_lib_IPOPT_gfortran}" DIRECTORY)

file(GLOB gfortran "${gcc_libdir}/libgfortran*.dylib")
file(GLOB quadmath "${gcc_libdir}/libquadmath*.dylib")
# Extract actual name of the library libgfortran, gcc, quadmath to install along on osx
# these show only as dependencies of libipopt, and libgcc is in same folder as libgfortran
# not very robust but works for our artifacts.
execute_process(COMMAND bash "-c"
"otool -L ${IPOPT_LIBDIR}/libipopt.dylib | grep 'libgfortran' | awk '{print $1}'"
OUTPUT_VARIABLE libgfortran_name
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Get the actual name of the library libgcc_s.1.dylib (can be libgcc_s.1.1.dylib),
# or another if it changes in the future.
string(REPLACE "libgfortran.5" "libgcc_s.1.1" libgcc_name ${libgfortran_name})

execute_process(COMMAND bash "-c"
"basename `otool -L ${IPOPT_LIBDIR}/libipopt.dylib | grep 'libgcc' | awk '{print $1}'`"
OUTPUT_VARIABLE libgcc_name
"otool -L ${IPOPT_LIBDIR}/libipopt.dylib | grep 'libquadmath' | awk '{print $1}'"
OUTPUT_VARIABLE libquadmath_name
OUTPUT_STRIP_TRAILING_WHITESPACE)

install(FILES
${ADOLC_DIR}/lib64/libadolc.2.dylib
${ADOLC_DIR}/lib64/libadolc.dylib
# /usr/local/opt/boost/lib/libboost_system.dylib
${ColPack_ROOT_DIR}/lib/libColPack.0.dylib
${IPOPT_LIBDIR}/libipopt.3.dylib
${IPOPT_LIBDIR}/libipopt.dylib
${IPOPT_LIBDIR}/../../mumps/lib/libcoinmumps.3.dylib
${IPOPT_LIBDIR}/../../mumps/lib/libcoinmumps.dylib
${IPOPT_LIBDIR}/../../metis/lib/libmetis.dylib
${IPOPT_LIBDIR}/libcoinmumps.3.dylib
${IPOPT_LIBDIR}/libcoinmumps.dylib
${IPOPT_LIBDIR}/libmetis.dylib
${libgfortran_name}
${libquadmath_name}
${libgcc_name}

DESTINATION ${CMAKE_INSTALL_LIBDIR})

Expand Down Expand Up @@ -59,10 +65,10 @@ elseif(TROPTER_COPY_DEPENDENCIES AND UNIX)
${IPOPT_LIBDIR}/libipopt.so.3.14.16
${IPOPT_LIBDIR}/libipopt.so.3
${IPOPT_LIBDIR}/libipopt.so
${IPOPT_LIBDIR}/../../mumps/lib/libcoinmumps.so.3.0.5
${IPOPT_LIBDIR}/../../mumps/lib/libcoinmumps.so.3
${IPOPT_LIBDIR}/../../mumps/lib/libcoinmumps.so
${IPOPT_LIBDIR}/../../metis/lib/libmetis.so
${IPOPT_LIBDIR}/libcoinmumps.so.3.0.5
${IPOPT_LIBDIR}/libcoinmumps.so.3
${IPOPT_LIBDIR}/libcoinmumps.so
${IPOPT_LIBDIR}/libmetis.so

${gfortran}
${quadmath}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ execute_process(COMMAND bash "-c"
# tropter
install_name_tool_change(tropter adolc.2 "@ADOLC_DIR@/lib64")
install_name_tool_change(tropter ipopt.3 "@IPOPT_LIBDIR@")
install_name_tool_change(tropter coinmumps.3 "@IPOPT_LIBDIR@")
install_name_tool_change(tropter coinmetis.1 "@IPOPT_LIBDIR@")
install_name_tool_add_rpath(tropter)

# adol-c
install_name_tool_id(adolc.2)
Expand All @@ -88,15 +85,20 @@ install_name_tool_delete_rpath(adolc.2 "@ColPack_ROOT_DIR@/lib")
# ipopt
install_name_tool_id(ipopt.3)
install_name_tool_change(ipopt.3 coinmumps.3 "@IPOPT_LIBDIR@")
install_name_tool_change(ipopt.3 coinmetis.1 "@IPOPT_LIBDIR@")
install_name_tool_change(ipopt.3 metis "@IPOPT_LIBDIR@")
install_name_tool_change_gfortran(ipopt.3)
install_name_tool_change_quadmath(ipopt.3)

# coinmumps
install_name_tool_id(coinmumps.3)
install_name_tool_change(coinmumps.3 coinmetis.1 "@IPOPT_LIBDIR@")
install_name_tool_change(coinmumps.3 metis "@IPOPT_LIBDIR@")
install_name_tool_change(coinmumps.3 "${libgcc_name}" "${libgcc_dir}")
install_name_tool_add_rpath(coinmumps.3)
install_name_tool_change_gfortran(coinmumps.3)
install_name_tool_change_quadmath(coinmumps.3)

# coinmetis
install_name_tool_id(coinmetis.1)
install_name_tool_add_rpath(coinmetis.1)
# metis
install_name_tool_id(metis)
install_name_tool_add_rpath(metis)


8 changes: 4 additions & 4 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ else()
ExternalProject_Add(metis
# URL http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz
URL https://sourceforge.net/projects/myosin/files/metis-5.1.0.tar.gz/download
CONFIGURE_COMMAND cd <SOURCE_DIR> && ${CMAKE_MAKE_PROGRAM} shared=1 config "prefix=${CMAKE_INSTALL_PREFIX}/metis" BUILDDIR=bdir
CONFIGURE_COMMAND cd <SOURCE_DIR> && ${CMAKE_MAKE_PROGRAM} shared=1 config "prefix=${CMAKE_INSTALL_PREFIX}/ipopt" BUILDDIR=bdir
BUILD_COMMAND cd <SOURCE_DIR>/bdir && ${CMAKE_MAKE_PROGRAM}
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/metis"
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/ipopt"
INSTALL_COMMAND cd <SOURCE_DIR>/bdir && ${CMAKE_MAKE_PROGRAM} install)

# GCC 10 generates a warning when compling MUMPS that we must suppress using
Expand All @@ -346,15 +346,15 @@ else()
PATCH_COMMAND cd <SOURCE_DIR> && ./get.Mumps
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> ADD_FFLAGS=-fallow-argument-mismatch ADD_CFLAGS=-Wno-error=implicit-function-declaration
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} ${BUILD_FLAGS}
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/mumps"
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/ipopt"
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install)

ExternalProject_Add(ipopt
DEPENDS mumps metis
URL https://github.com/coin-or/Ipopt/archive/refs/tags/releases/3.14.16.zip
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/ipopt"
# Suppress warnings treated as errors in Clang/LLVM with -Wno-error=implicit-function-declaration
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-mumps --prefix=<INSTALL_DIR> --with-mumps-cflags="-I${CMAKE_INSTALL_PREFIX}/mumps/include/coin-or/mumps" --with-mumps-lflags="-L${CMAKE_INSTALL_PREFIX}/mumps/lib -lcoinmumps"
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-mumps --prefix=<INSTALL_DIR> --with-mumps-cflags="-I${CMAKE_INSTALL_PREFIX}/ipopt/include/coin-or/mumps" --with-mumps-lflags="-L${CMAKE_INSTALL_PREFIX}/ipopt/lib -lcoinmumps"
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} ${BUILD_FLAGS}
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install)
endif()
Expand Down

0 comments on commit 9595a4a

Please sign in to comment.