esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
804 stars 159 forks source link

[BUG] Could NOT find pagmo_IPOPT (missing: PAGMO_IPOPT_INCLUDE_DIR) #529

Open intractabilis opened 1 year ago

intractabilis commented 1 year ago

Describe the bug pagmo needs manual specification of PAGMO_IPOPT_INCLUDE_DIR, otherwise Findpagmo_IPOPT.cmake fails with an error.

To Reproduce Build pagmo with PAGMO_WITH_IPOPT=ON, create a project with the following meson.build

project('test', ['cpp'], version : '0.1')
pagmo_dep = dependency('pagmo', method: 'cmake')
executable(test, 'test.cpp', dependencies: [pagmo_dep])

Run meson setup build. Meson will fail to find pagmo with the following message in the log file:

ERR:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find pagmo_IPOPT (missing: PAGMO_IPOPT_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /somewhere/gcc-env/lib/cmake/pagmo/Findpagmo_IPOPT.cmake:33 (find_package_handle_standard_args)
  /somewhere/gcc-env/lib/cmake/pagmo/pagmo-config.cmake:13 (find_package)
  CMakeLists.txt:16 (find_package)

Please, use pkgconf to find PAGMO_IPOPT_INCLUDE_DIR. Suggested change for Findpagmo_IPOPT.cmake:

@@ -15,6 +15,9 @@ unset(_pagmo_IPOPT_ALLOWED_COMPONENTS)
 # find_package_handle_standard_args().
 set(_pagmo_IPOPT_FPHSA_ARGS)

+find_package(PkgConfig REQUIRED)
+pkg_get_variable(PAGMO_IPOPT_INCLUDE_DIR ipopt includedir)
+
 if ("header" IN_LIST pagmo_IPOPT_FIND_COMPONENTS)
     # The header component was requested.
     # The associated variable is PAGMO_IPOPT_INCLUDE_DIR.
bluescarni commented 1 year ago

I am not sure pkgconfig is the way to go, since as far as I recall it's not really well-supported/widespread in Windows environments.

In out CI, IPOPT is located without much effort even when installed in non-standard paths (e.g., from a conda environment). Could you give a bit more context/explanation about the error? E.g., were the CMAKE_INSTALL_PREFIX and CMAKE_PREFIX_PATH CMake variables set up properly?