'Install IPOPT locally into C++ codebase with CMake ExternalProject

I would like to use Ipopt in a CMake-based project using ExternalProject. The library should be installed locally and automatically in the build folder so that the user must not go through any hassle.

I can do this for simple enough repositories that do not have many dependencies; unfortunately, this is not the case for Ipopt, whose installation requires a set of packages to be installed first.

How can install and use Ipopt in a local, self-contained way using CMake ExternalProject? If this cannot be done, is there an approach that would make the process at least partially self-contained? I would be very grateful for any answer with a working CMake script!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source