IpOpt can be installed as iCub dependency, as stand-alone binaries, or compiled by getting the sources directly from the web. See below.
Visit the iCub Software Installation page and follow the guide for installing from sources: this way you will get IpOpt installed as a dependency.
Let us enforce that INSTALLING IPOPT AS A DEPENDENCY IS THE RECOMMENDED SOLUTION, which minimizes how package maintenance impacts your system.
Install from binaries distribution
Ipopt can be easily installed via vcpkg.
Firstly get robotology-vcpkg-binary-ports, then:
./vcpkg.exe --overlay-ports=<repo_parent_directory>/robotology-vcpkg-binary-ports install ipopt-binary:x64-windows
sudo apt install coinor-libipopt-dev
Ipopt can be easily installed via homebrew:
brew install ipopt