CMake Not Finding HSL and METIS Libraries when Building CasADi + IPOPT + HSL in Dockerfile

Hi everyone,

I’m trying to build CasADi with IPOPT and HSL inside a Docker environment. I’ve been following the instructions from this guide, but I keep running into an issue with CMake not being able to locate the HSL and METIS libraries.

Here’s a summary of the issue:

Problem Details:

When building inside the Dockerfile, I encounter the following errors during the CMake configuration process:

-- x86_64 architecture detected - setting flag -fPIC
HSL: find via CONFIG
-- Could NOT find HSL (missing: HSL_DIR)
HSL: 0
-- Could not find HSL; looking in environmental variable HSL ()
debug HSL_FOUND
get_property(PKG_HELP CACHE WITH_BUILD_IPOPT PROPERTY HELPSTRING)
get_property(PKG_HELP CACHE WITH_BUILD_MUMPS PROPERTY HELPSTRING)
METIS: find via CONFIG
-- Could NOT find METIS (missing: METIS_DIR)
METIS: 0
-- Found METIS: /usr/lib/x86_64-linux-gnu/libmetis.so
-- Found METIS include dir: /usr/include

CMake Command in Dockerfile:

Here’s the CMake and make commands I’m using in the Dockerfile:

cd /root/robot-code/casadi/build && \

cmake \
    -DWITH_IPOPT:BOOL=ON \
    -DWITH_HSL:BOOL=ON \
    -DWITH_PYTHON=ON \
    -DINCLUDE_PREFIX:PATH=/robot-code/CoinIpopt/install/include \
    -DCMAKE_PREFIX:PATH=lib/cmake/casadi \
    -DLIB_PREFIX:PATH=/robot-code/CoinIpopt/install/lib \
    -DBIN_PREFIX:PATH=/robot-code/CoinIpopt/install/bin  ..

make && \

make install

What I’ve Tried:

Here’s what’s strange:

  • When I run the last three commands manually in the terminal, everything works perfectly, and HSL is correctly detected and used by CMake. However, when these exact same commands are executed in the Dockerfile, I get the error that HSL cannot be found.

I suspect this issue might be related to how the environment is set up in the Docker build context, but I haven’t been able to pinpoint the exact cause.

Questions:

  1. Has anyone encountered similar issues when building CasADi, IPOPT, and HSL within Docker, where the build works manually but fails inside the Dockerfile?
  2. Could there be a difference in how environment variables or paths are handled in the Docker build context versus an interactive shell, causing the HSL_DIR or METIS_DIR to not be set correctly?
  3. Are there any specific flags I should add to CMake or Docker to ensure the paths for HSL and METIS are resolved correctly?

Any guidance or suggestions would be greatly appreciated!

Thanks in advance for any help!